TreeList.GetSelectImage Event
Allows you to assign select images to nodes.
Namespace: DevExpress.XtraTreeList
Assembly: DevExpress.XtraTreeList.v24.2.dll
NuGet Packages: DevExpress.Win.Navigation, DevExpress.Win.TreeList
#Declaration
public event GetSelectImageEventHandler GetSelectImage
#Event Data
The GetSelectImage event's data class is GetSelectImageEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Focused |
Gets or sets a value indicating whether a node is focused. |
Node |
Gets the current Tree List node.
Inherited from Node |
Node |
Gets or sets the index of the node’s image in a source image list.
When handling the Tree |
#Remarks
Nodes can display the following icons:
- Select Image - two icons that automatically switch when a node gets / loses the focus.
- State Image - any custom icon.
#Select Image
#Specify image source
The TreeList.SelectImageList property specifies an ordered (indexed) collection that stores images. You can use the following image collections:
- ImageList — manages a collection of Image objects.
- ImageCollection — provides additional functionality compared to the ImageList class.
- SharedImageCollection — shares images between multiple controls and forms.
- SvgImageCollection — stores vector images.
#Assign images to nodes
To specify the index of the image displayed in a particular node, use the following properties and events:
the TreeList.ImageIndexFieldName property — specifies the name of the data field that contains image indexes. The property specifies the image index for both non-focused and focused states (you cannot use data source fields to specify two icons).
the TreeListNode.ImageIndex and TreeListNode.SelectImageIndex properties — get or set the node’s image index in the non-focused and focused states, respectively. Images are automatically changed when a node gets / loses the focus.
Note
The Select
Image and ImageIndex Index properties are not in effect if the TreeList obtains image indices from a data source field ( ImageIndex ).Field Name the
TreeList.GetSelectImage
event — fires before a node is displayed and allows you to specify (override) the image index for the processed node.
If the index is out of range, no image is displayed.
#Respond to clicks
The TreeList.RowSelectImageClick event fires when a select image is clicked.
#Example
This code below shows how to handle the TreeList.GetSelectImage
event to assign select images to nodes depending on the focus state.
using DevExpress.XtraTreeList;
treeList1.SelectImageList = imageCollection1;
private void treeList1_GetSelectImage(object sender, GetSelectImageEventArgs e) {
if (e.FocusedNode)
e.NodeImageIndex = 2;
else
e.NodeImageIndex = 0;
}