Skip to main content

TcxCustomTreeView.AlphaSort(Boolean) Method

Sorts tree nodes.

Declaration

function AlphaSort(ARecurse: Boolean = True): Boolean;

Parameters

Name Type
ARecurse Boolean

Returns

Type
Boolean

Remarks

Call the AlphaSort method to sort nodes within the tree view control. By default, the method sorts nodes by their captions. If nodes are not currently sorted, ascending sort order is applied. If the nodes are already sorted, AlphaSort toggles sort order.

The ARecursive parameter specifies whether nodes at all nesting levels must be sorted. Specify False as its value to sort only root level nodes. Note that this parameter is optional and is True by default.

If an OnCompare event handler has been written, it is used to compare nodes when sorting using the AlphaSort method. This enables you to implement custom algorithms of node sorting.

Note that calling the AlphaSort method is equivalent to calling the CustomSort method with the first parameter set to nil. AlphaSort simply calls this method to perform sorting. You can also sort nodes within the tree view by calling the AlphaSort method of the TTreeNodes object standing for the Items property of the control. If you need to sort an individual branch within the tree, call the AlphaSort method of the TTreeNode object representing the desired parent node.

The AlphaSort method is used when the control performs automatic node sorting. This takes place when the SortType property of the control is set to a value different than stNone. If the SortType property is set to stText, the AlphaSort method is automatically called each time the Text property of any node at the root level changes. If changing node text located at other nesting levels, the AlphaSort method of the TTreeNode object representing this node’s parent is called. If the SortType property is set to stData, these methods are called each time the Data node property is changed. Finally, setting the SortType property to stBoth forces the control to call these methods when either the Text or Data property of nodes are changed.

See Also