TreeList.GetStateImage Event
Allows you to assign state images to nodes.
Namespace: DevExpress.XtraTreeList
Assembly: DevExpress.XtraTreeList.v18.1.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.
Example
This code provides an example of handling the TreeList.GetSelectImage event used to assign select images to nodes. A green dot glyph is assigned to non-focused nodes, and a red dot glyph is assigned to the focused node. Note that an image list containing these glyphs must be assigned to the TreeList.SelectImageList property.
using DevExpress.XtraTreeList;
private void treeList1_GetSelectImage(object sender, GetSelectImageEventArgs e) {
if (e.FocusedNode)
e.NodeImageIndex = 2;
else
e.NodeImageIndex = 0;
}
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references 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.