[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Collapse]Windows 10 App Controls
  Prerequisites
 [Expand]Getting Started
 [Expand]Controls
 [Expand]Themes and Color Schemes
  Localization
  Get More Help
 [Collapse]API Reference
  [Expand]DevExpress.Core
  [Expand]DevExpress.Data
  [Expand]DevExpress.Data.Filtering
  [Expand]DevExpress.Mvvm
  [Expand]DevExpress.Mvvm.UI
  [Expand]DevExpress.UI.Xaml
  [Expand]DevExpress.UI.Xaml.Charts
  [Expand]DevExpress.UI.Xaml.Controls
  [Expand]DevExpress.UI.Xaml.Controls.Internal.Pdf
  [Expand]DevExpress.UI.Xaml.Editors
  [Expand]DevExpress.UI.Xaml.Editors.Native
  [Expand]DevExpress.UI.Xaml.Gauges
  [Collapse]DevExpress.UI.Xaml.Grid
   [Expand]AddingNewEventArgs Class
    AutoFilterCondition Enumeration
   [Expand]ColumnBase Class
   [Expand]ColumnCollection Class
    ColumnFilterMode Enumeration
   [Expand]CustomColumnSortEventArgs Class
    CustomColumnSortEventHandler Delegate
   [Expand]DataControlBase Class
    ExceptionMode Enumeration
    FilterPopupMode Enumeration
    FindMode Enumeration
   [Expand]GridCell Class
   [Expand]GridCheckBoxColumn Class
   [Expand]GridColumnBase Class
   [Expand]GridColumnCollection Class
   [Expand]GridColumnCommands Class
   [Expand]GridColumnDataEventArgs Class
    GridColumnDataEventHandler Delegate
   [Expand]GridComboBoxColumn Class
   [Collapse]GridControl Class
     GridControl Members
     GridControl Constructor
    [Expand]GridControl Properties
    [Collapse]GridControl Events
      AddingNewRow Event
      ContextMenuClosed Event
      ContextMenuOpened Event
      ContextMenuOpening Event
      CustomColumnGroup Event
      CustomColumnSort Event
      CustomSummary Event
      CustomSummaryExists Event
      CustomUnboundColumnData Event
      EndGrouping Event
      EndSorting Event
      GroupRowCollapsed Event
      GroupRowCollapsing Event
      GroupRowExpanded Event
      GroupRowExpanding Event
      InitNewRow Event
      StartGrouping Event
      StartSorting Event
      ValidateCell Event
      ValidateRow Event
    [Expand]GridControl Methods
   [Expand]GridControlBase Class
   [Expand]GridControlCommands Class
    GridControlNavigationStyle Enumeration
   [Expand]GridDateColumn Class
   [Expand]GridMaskColumn Class
   [Expand]GridSpinEditColumn Class
    GridSummaryItemAlignment Enumeration
   [Expand]GridTemplateColumn Class
   [Expand]GridTextColumn Class
   [Expand]GridTextColumnBase Class
   [Expand]GridTotalSummaryData Class
    GroupSummaryDisplayMode Enumeration
   [Expand]HighlightingSettings Class
   [Expand]InitNewRowEventArgs Class
   [Expand]InvalidRowExceptionEventArgs Class
    MultiSelectMode Enumeration
    NewItemRowPosition Enumeration
   [Expand]RowEventArgs Class
    RowEventHandler Delegate
    ScrollAnimationMode Enumeration
    ShowFilterPanelMode Enumeration
    ShowSearchPanelMode Enumeration
   [Expand]SummaryItemBase Class
  [Expand]DevExpress.UI.Xaml.Grid.Native
  [Expand]DevExpress.UI.Xaml.Layout
  [Expand]DevExpress.UI.Xaml.Layout.Base
  [Expand]DevExpress.UI.Xaml.Layout.Internal
  [Expand]DevExpress.UI.Xaml.Layout.VisualElements
  [Expand]DevExpress.UI.Xaml.Map
  [Expand]DevExpress.UI.Xaml.Ribbon
  [Expand]DevExpress.Utils
  [Expand]DevExpress.XtraGrid
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

GridControl.CustomColumnSort Event

Enables you to sort data using custom rules.

Namespace:DevExpress.UI.Xaml.Grid
Assembly:DevExpress.UI.Xaml.Grid.v18.1.dll

Expanded Syntax

Expanded Event Data

The event handler receives an argument of type CustomColumnSortEventArgs containing data related to this event.

The following CustomColumnSortEventArgs properties provide information specific to this event.
Property Description
Column Gets the column whose values are being compared.
Handled Gets or sets whether a comparison operation is handled and no default processing is required.
ListSourceRowIndex1 Gets the index of the first of the two rows being compared in the data source.
ListSourceRowIndex2 Gets the index of the second of the two rows being compared in the data source.
Result Gets or sets the result of a custom comparison.
SortOrder Gets the sort order applied to the column.
Source Gets the grid control that raised the event.
Value1 Gets the first value being compared.
Value2 Gets the second value being compared.

Expanded Remarks

To sort column values using custom logic, set a column's ColumnBase.SortMode property to ColumnSortMode.Custom, and handle the CustomColumnSort event.

When this event is fired, two rows should be compared. The column being processed is specified by the Column parameter. The Value1 and Value2 parameters identify the values of the rows within this column. The result of the custom comparison should be set to the Result parameter as follows:

  • -1 if the first row should be positioned above the second row when data is sorted in ascending order. When data is sorted in descending order, the first row will be positioned below the second row.
  • 1 if the first row should be positioned below the second row when data is sorted in ascending order. When data is sorted in descending order, the first row will be positioned above the second row.
  • 0 to indicate that the rows are equal. In this case, the rows will be arranged within a grid according to their indices in a data source.

The event parameter's Handled property should be set to true if the comparison operation was handled. You can leave this parameter set to false to invoke the default comparison mechanism after your event handler has finished. In this instance, the custom comparison operation's result is ignored.

Expanded See Also

Is this topic helpful?​​​​​​​