State image: Specify image source
The TreeList.StateImageList property specifies an ordered (indexed) collection that stores images. You can use the following image collections:
State image: Assign images to nodes
To specify the index of the image displayed in a particular node, use the following properties and events:
-
the StateImageIndex property — gets or sets the image index.
-
the TreeList.GetStateImage 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.
State image: Respond to clicks
The TreeList.RowStateImageClick event fires when a state image is clicked.
The code below shows how to assign select and state images to nodes.
C# |
using DevExpress.XtraTreeList.Nodes;
treeList1.SelectImageList = imageCollection1;
treeList1.ImageIndexFieldName = "ImageIndex";
treeList1.StateImageList = imageCollection1;
treeList1.Load += TreeList1_Load;
private void TreeList1_Load(object sender, EventArgs e) {
foreach (TreeListNode node in treeList1.Nodes) {
node.ImageIndex = 0;
node.SelectImageIndex = 1;
node.StateImageIndex = 2;
}
}
|
VB |
Imports DevExpress.XtraTreeList.Nodes
treeList1.SelectImageList = imageCollection1
treeList1.ImageIndexFieldName = "ImageIndex"
treeList1.StateImageList = imageCollection1
AddHandler treeList1.Load, AddressOf TreeList1_Load
Private Sub TreeList1_Load(ByVal sender As Object, ByVal e As EventArgs)
For Each node As TreeListNode In treeList1.Nodes
node.ImageIndex = 0
node.SelectImageIndex = 1
node.StateImageIndex = 2
Next node
End Sub
|