IDimensionViewer.OnCompareItems

Syntax

Sub OnCompareItems(Sender: Object; Args: IDimensionViewerCompareEventArgs);

Begin

//set of operators;

End Sub OnCompareItems;

Parameters

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

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

Description

The OnCompareItems event occurs on comparing two elements during user element sorting.

Example

Executing the example requires a form with the Button1 button and the DimensionTree component named DimensionTree1. Elements in the second column contain integer values.

Class TestForm: Form

DimensionTree1: DimensionTree;

UiDimension1: UiDimension;

Button1: Button;

AttrInst: IDimAttributeInstance;

 

Sub DimensionTree1OnCompareItems(Sender: Object; Args: IDimensionViewerCompareEventArgs);

Var

i, j: Integer;

Begin

i := AttrInst.Value(Args.LeftItem);

j := AttrInst.Value(Args.RightItem);

If i > j Then

Args.Compare := -1;

Else

Args.Compare := 1;

End If;

End Sub DimensionTree1OnCompareItems;

 

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);

Var

Inst: IDimInstance;

Begin

Inst := UiDimension1.DimInstance;

AttrInst := Inst.Attributes.Item(1);

DimensionTree1.SortType := ControlSortType.Custom;

DimensionTree1.SortColumn := 1;

DimensionTree1.Sorted := True;

DimensionTree1.SortDefault;

End Sub Button1OnClick;

End Class TestForm;

After executing the example, on clicking the button, custom sorting based on the values of the second component column is executed. Values are sorted in descending order.

See also:

IDimensionViewer