TreeListView.CustomColumnSort Event

Enables you to sort data using custom rules.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v20.1.dll

Declaration

public event TreeListCustomColumnSortEventHandler CustomColumnSort
Public Event CustomColumnSort As TreeListCustomColumnSortEventHandler

Event Data

The CustomColumnSort event's data class is TreeListCustomColumnSortEventArgs. The following 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.
Node1 Gets the first of the two nodes being compared.
Node2 Gets the second of the two nodes being compared.
Result Gets or sets the result of a custom comparison.
SortOrder Gets the sort order applied to the column.
Value1 Gets the first value being compared.
Value2 Gets the second value being compared.

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 nodes should be compared. The column being processed is specified by the TreeListCustomColumnSortEventArgs.Column parameter. The TreeListCustomColumnSortEventArgs.Value1 and TreeListCustomColumnSortEventArgs.Value2 parameters identify the values of the nodes within this column. The result of the custom comparison should be set to the TreeListCustomColumnSortEventArgs.Result parameter as follows:

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

The event parameter's TreeListCustomColumnSortEventArgs.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.

To learn more, see Sorting Modes and Custom Sorting.

See Also