Dear Team,
In old times i used this code to have a custom sort on a datagridview:
Private Sub DG_RM_SortCompare(sender As Object, e As DataGridViewSortCompareEventArgs) Handles DG_RM.SortCompare
'''' <summary>Gets or sets a value indicating the order in which the compared cells will be sorted.</summary>
'''' <returns>Less than zero if the first cell will be sorted before the second cell; zero if the first cell and second cell have equivalent values; greater than zero if the second cell will be sorted before the first cell.</returns>
If e.Column.Index > 2 Then
Try
If e.CellValue1 Is Nothing OrElse e.CellValue1.Equals(DBNull.Value) Then
If e.CellValue2 Is Nothing OrElse e.CellValue2.Equals(DBNull.Value) Then
e.SortResult = 0
Else
e.SortResult = 1
End If
Else
If e.CellValue2 Is Nothing OrElse e.CellValue2.Equals(DBNull.Value) Then
e.SortResult = -1
Else
e.SortResult = DirectCast(e.CellValue1, IComparable).CompareTo(DirectCast(e.CellValue2, IComparable))
End If
End If
e.Handled = True
Catch ex As Exception
MsgBox(Err.Description)
Close()
End Try
End If
End Sub
Now i need to achieve the same in WPF radgridview.. I have columns, with positive integers, zeroes and NULLs too.
Basically if i order : NULLs come first , then zeroes, then numbers ASC.
In my case customer needs to see in this way: zeroes, positive numbers asc, and nulls at the end.
The datasource is a datatable passed to radgridview as itemsource, and the column names (and number of them) are always dynamic, so i cannot predefine them in the XAML section. Please help
Thanks!
Peter B. (Hungary)