
February 9th, 2013, 05:16 PM
|
|
Registered User
|
|
Join Date: Feb 2013
Posts: 1
Time spent in forums: 2 m 51 sec
Reputation Power: 0
|
|
Sorting column in datagridview populated by array
Below is my code. I need to sort the output of the "z" column descending by value. Any ideas?
Private Sub btnTableDeg_Click(sender As Object, e As EventArgs) Handles btnTableDeg.Click
' Clears rows on button press and builds columns
DataGridView1.Rows.Clear()
DataGridView1.ColumnCount = 3
DataGridView1.Columns(0).HeaderText = "Field of Study"
DataGridView1.Columns(1).HeaderText = "1981"
DataGridView1.Columns(2).HeaderText = "2006"
' One dimensional arrays initializing values
Dim x() As String = {("Business"), ("Computer & info.science"), ("Education"), ("Engineering"), ("Social science and history")}
Dim y() As Integer = {("200,521"), ("15,121"), ("108,074"), ("63,642"), ("100,513")}
Dim z() As Integer = {("318,042"), ("47,480"), ("107,238"), ("67,045"), ("161,485")}
'Calling output from arrays for datagridview
DataGridView1.Rows.Add(x(0), (y(0)), z(0))
DataGridView1.Rows.Add(x(1), (y(1)), z(1))
DataGridView1.Rows.Add(x(2), (y(2)), z(2))
DataGridView1.Rows.Add(x(3), (y(3)), z(3))
DataGridView1.Rows.Add(x(4), (y(4)), z(4))
End Sub
|