|
-
Nov 8th, 2006, 06:49 PM
#1
Thread Starter
Lively Member
Where "Out of Range" on Datagrideview SelectedColumns ?
Did some research and found out how to programmetically sort the DGV. Setup 2 radio buttons to test it out with the following code, when I ran, I got an err msg pointing at "SelectedColumns(1)"
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name:index
Can someone please tell me where is it "Out of range" ? I'm trying to sort based on column 1 data.
----VB Code
Private Sub Sort_Ascending(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbAsc.CheckedChanged
If rbAsc.Checked Then
Dim newColumn As DataGridViewColumn
newColumn = Me.dgvMaterial_Inventory.SelectedColumns(1)
Me.dgvMaterial_Inventory.Sort(newColumn, System.ComponentModel.ListSortDirection.Ascending)
End If
End Sub
Private Sub Sort_Descending(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbDesc.CheckedChanged
If rbDesc.Checked Then
Dim newColumn As DataGridViewColumn
newColumn = Me.dgvMaterial_Inventory.SelectedColumns(1)
Me.dgvMaterial_Inventory.Sort(newColumn, System.ComponentModel.ListSortDirection.Descending)
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|