All docs
V20.2
21.1 (EAP/Beta)
20.2
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

TreeViewControl.CustomNodeSort Event

Allows you to use custom rules to sort data.

Namespace: DevExpress.Xpf.Grid

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

Declaration

public event TreeViewCustomNodeSortEventHandler CustomNodeSort

Event Data

The CustomNodeSort event's data class is DevExpress.Xpf.Grid.TreeList.TreeViewCustomNodeSortEventArgs.

Remarks

Set the SortMode property to Custom and handle the CustomNodeSort event to apply custom logic to sort data.

When you handle this event, you need to compare two nodes. The Value1 and Value2 parameters identify the values of these nodes. Set the result of the comparison to the Result parameter as follows:

  • -1 to position the first row above the second row when data is sorted in ascending order. When data is sorted in descending order, the TreeViewControl positions the first row below the second row.
  • 1 to position the first row below the second row when data is sorted in ascending order. When data is sorted in descending order, the TreeViewControl positions the first row above the second row.
  • 0 to indicate that the rows are equal. In this case, the TreeViewControl arranges rows according to their indices in a data source.

Set the Handled parameter to true to use the custom comparison. Leave this parameter set to false to invoke the default comparison mechanism after your event handler has finished. In this instance, the TreeViewControl ignores the custom comparison's result.

Example

<dxg:TreeViewControl SortMode="Custom" 
                     CustomNodeSort="treeview_CustomNodeSort"
                     SortOrder="Ascending"
                     ...>
void treeview_CustomNodeSort(object sender, DevExpress.Xpf.Grid.TreeList.TreeViewCustomNodeSortEventArgs e) {
    int dayIndex1 = GetDayIndex((string)e.Value1);
    int dayIndex2 = GetDayIndex((string)e.Value2);
    e.Result = dayIndex1.CompareTo(dayIndex2);
    e.Handled = true;
}
See Also