Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

CustomColumnSortEventArgs Class

Provides data for the GridControl.CustomColumnSort event.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v24.2.dll

NuGet Package: DevExpress.Wpf.Grid.Core

#Declaration

public class CustomColumnSortEventArgs :
    EventArgs

#Remarks

To learn more, see Sorting Modes and Custom Sorting.

#Example

The following example demonstrates how to use custom rules to sort data in the GridControl:

DevExpress WPF | Grid Control - Custom Sort Rules

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);
}

#Inheritance

Object
EventArgs
CustomColumnSortEventArgs
See Also