TreeList.GetSelectImage Event

Allows you to assign select images to nodes.

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v20.1.dll

Declaration

public event GetSelectImageEventHandler GetSelectImage
Public Event GetSelectImage As GetSelectImageEventHandler

Event Data

The GetSelectImage event's data class is GetSelectImageEventArgs. The following properties provide information specific to this event:

Property Description
FocusedNode Gets or sets a value indicating whether a node is focused.
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. Inherited from GetStateImageEventArgs.

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.

veNodeImage

Select Image

Specify image source

The TreeList.SelectImageList property specifies an ordered (indexed) collection that stores images. You can use the following image collections:

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.

  • 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.

Examples

This code below shows how to handle the TreeList.GetSelectImage event to assign select images to nodes depending on the focus state.

Images - GetSelectStateImage

using DevExpress.XtraTreeList;

treeList1.SelectImageList = imageCollection1;

private void treeList1_GetSelectImage(object sender, GetSelectImageEventArgs e) {
    if (e.FocusedNode)
        e.NodeImageIndex = 2;
    else
        e.NodeImageIndex = 0;
}
See Also