ITreeControl.OnCompareItems

Syntax

OnCompareItems(Sender: Object; Args: ITreeControlCompareEventArgs);

Parameters

Sender. The parameter that returns the component that has generated the event.

Args. The parameter that enables the user to determine event parameters.

Description

The OnCompareItems event occurs when two elements are compared during the custom sorting of elements.

Example

Executing the example requires a form with a button named Button1 on the form and the TreeList component named TreeList1. The SortType property of the TreeList1 component is set to Custom value. The elements in the second column contain integer values.

Sub TreeList1OnCompareItems(Sender: Object; Args: ITreeControlCompareEventArgs);
Var
    Nod1, Nod2: ITreeListNode;
Begin
    Nod1 := Args.LeftItem;
    Nod2 := Args.RightItem;
    If Integer.Parse(Nod1.ColumnText(1)) > Integer.Parse(Args.RightItem.ColumnText(1)) Then
        Args.Compare := -1;
    Else
        Args.Compare := 1;
    End If;
End Sub TreeList1OnCompareItems;

When the event occurs, the elements are sorted depending on the value of the element in the second column.

See also:

ITreeControl