« on: May 29, 2012, 02:24:22 AM »
Datagridview - Sorting Numeric Columns that are not bound to a DataSource
http://tedshelloworld.blogspot.com/2008/05/datagridview-sorting-numeric-columns.html Private Sub dgvSample_SortCompare(sender As Object, e As System.Windows.Forms.DataGridViewSortCompareEventArgs) Handles dgvSample.SortCompare
If e.Column.Index = 1 Then
If Integer.Parse(e.CellValue1) > Integer.Parse(e.CellValue2) Then
e.SortResult = 1
ElseIf Integer.Parse(e.CellValue1) < Integer.Parse(e.CellValue2) Then
e.SortResult = -1
Else
e.SortResult = 0
End If
e.Handled = True
Exit Sub
End If
End Sub
« Last Edit: June 12, 2012, 01:57:52 AM by Roy Chan »
Logged