[Overview][Constants][Types][Classes][Procedures and functions][Index] | Reference for unit 'ComCtrls' (#lcl)

# TCustomTreeView.OnCompare

Event handler signalled to compare and sort tree nodes in their default order.

## Declaration

Source position: comctrls.pp line 3672

`protected property TCustomTreeView.OnCompare : TTVCompareEvent read FOnCompare write FOnCompare;`

## Description

OnCompare is a TTVCompareEvent property with the event handler signalled to compare nodes on the tree view control. It is signalled (when assigned) to determine the sort order for tree nodes in the DefaultTreeViewSort method. Arguments to the event handler include:

Sender
  The tree view control for the event.
Node1, Node2
  The tree nodes compared in the handler routine.
Compare
  An Integer value with the relative sort order for the compared nodes. <0 indicates that Node1 comes before Node2 in the sort order. <0 indicates that Node1 comes after Node2 in the sort order. 0 means that Node1 and Node2 have the same value in the sort order.

If OnCompare is not assigned, the sort order for tree nodes is determined using the AnsiCompareStr (on Windows) or CompareStr (on UNIX-like platforms) routines.

## See also

TCustomTreeView.DefaultTreeViewSort |  | DefaultTreeViewSort - returns result of string comparison between names of Node1 and Node2
TCustomTreeView.CustomSort |  | If True, the external method specified in SortProc is used for sorting.
TCustomTreeView.AlphaSort |  | Sorts tree nodes using default sort procedure (alphabetic).