Sub OnGetNodeStateImage(Sender: Object; Args: ITreeNodeGetImageEventArgs);
Begin
//set of operators;
End Sub OnGetNodeStateImage;
Sender. Parameter that returns the component that has generated the event.
Args. Parameter that enables the user to determine event parameters.
The OnGetNodeStateImage event is used on determining the state image near the tree element.
The event is relevant only if the StateImages property is determined for the component.
The event occurs for each tree element in the following cases:
Form parameters are changed: size, state.
Form contents is updated.
Component parameters are changed: element list is changed, hierarchy is collapsed/expanded, element selection or focus is changed.
Element tree is scrolled.
Component contents is updated.
Using the OnGetNodeStateImage event enables the user to trace changes and, if a certain event occurs, to get or to change element tree state image. The element, for which the current event is generated, is available in the Node property of the Args event argument. The Result property of the event argument provides state image index that is set for the element. If a new value for the Result property is set, it is possible to change state image for the element.
Executing the example requires a form with the TreeList component named TreeList1 and any ImageList component, which is state image source for TreeList1. At least two images are loaded to ImageList.
Sub TreeList1OnGetNodeStateImage(Sender: Object; Args: ITreeNodeGetImageEventArgs);
Begin
If Args.Node.Selected Then
Args.Result := 0;
Else
Args.Result := 1;
End If;
End Sub TreeList1OnGetNodeStateImage;
When the event occurs, element selection is checked. If the element is selected, the first image from image collection will be used for state image. If the element is not selected, the second state image is set.
See also: