TreeList.GetStateImage Event
Allows you to assign state images to nodes.
Namespace: DevExpress.XtraTreeList
Assembly: DevExpress.XtraTreeList.v18.2.dll
Declaration
Event Data
The GetStateImage event's data class is GetStateImageEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Node | Gets the current Tree List node. Inherited from NodeEventArgs. |
NodeImageIndex |
Gets or sets the index of the node’s image in a source image list. When handling the TreeList.GetStateImage event, the source of images is specified by the TreeList.StateImageList property. When handling the TreeList.GetSelectImage event, the source of images is specified by the TreeList.SelectImageList property. |
Remarks
Tree List nodes can display select and state images.
The GetStateImage event allows you to dynamically assign state images to nodes. Other ways to specify state images are covered in the TreeList.StateImageList topic.
Before handling the GetStateImage event, specify the source of state images with the TreeList.StateImageList property.
The GetStateImage event fires for each node within the Tree List. Parameters passed to your event handler allow you to identify the currently processed node, determine whether it is focused and assign the index of a required image from the source image list to the node.
The code sample below illustrates how to add icons for the Checked states of tree nodes.
ImageCollection collection = new ImageCollection();
collection.Images.AddRange(new Image[] { img, img2 });
treeList1.StateImageList = collection;
treeList1.GetStateImage += treeList1_GetStateImage;
private void treeList1_GetStateImage(object sender, GetStateImageEventArgs e)
{
if (e.Node.Checked)
e.NodeImageIndex = 1;
else
e.NodeImageIndex = 0;
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the GetStateImage event.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.