wpf-devexpress-dot-xpf-dot-grid-afb76ad5.md
Provides data for the GridControl.CustomColumnSort event.
Namespace : DevExpress.Xpf.Grid
Assembly : DevExpress.Xpf.Grid.v25.2.dll
NuGet Package : DevExpress.Wpf.Grid.Core
public class CustomColumnSortEventArgs :
EventArgs
Public Class CustomColumnSortEventArgs
Inherits EventArgs
CustomColumnSortEventArgs is the data class for the following events:
To learn more, see Sorting Modes and Custom Sorting.
The following example demonstrates how to use custom rules to sort data in the GridControl:
View Example: How to Use Custom Rules to Sort Data
<dxg:GridControl x:Name="grid"
CustomColumnSort="OnCustomColumnSort">
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="Day" GroupIndex="0" SortMode="Custom"/>
<dxg:GridColumn FieldName="Employee"/>
</dxg:GridControl.Columns>
</dxg:GridControl>
void OnCustomColumnSort(object sender, CustomColumnSortEventArgs e) {
if(e.Column.FieldName == "Day") {
int dayIndex1 = GetDayIndex(e.Value1);
int dayIndex2 = GetDayIndex(e.Value2);
e.Result = dayIndex1.CompareTo(dayIndex2);
e.Handled = true;
}
}
int GetDayIndex(object day) {
return (int)Enum.Parse(typeof(DayOfWeek), (string)day);
}
Private Sub OnCustomColumnSort(ByVal sender As Object, ByVal e As DevExpress.Xpf.Grid.CustomColumnSortEventArgs)
If Equals(e.Column.FieldName, "Day") Then
Dim dayIndex1 As Integer = Me.GetDayIndex(e.Value1)
Dim dayIndex2 As Integer = Me.GetDayIndex(e.Value2)
e.Result = dayIndex1.CompareTo(dayIndex2)
e.Handled = True
End If
End Sub
Private Function GetDayIndex(ByVal day As Object) As Integer
Return CInt(System.[Enum].Parse(GetType(System.DayOfWeek), CStr(day)))
End Function
Object EventArgs CustomColumnSortEventArgs
See Also