You can display an icon with treeview control. You can simply display the icons that are positioned to the left of the nodes.
To display these icons, you must associate the tree view with an ImageList control.
In this article we will learn that how you can be do this in the designer with the Properties window, or in code.
Set the icons to nodes in designer:
follow these steps:
1. Add a ImageList control.
2. Goto ImageList’s properties windows, add images to ImageList control.
3. Set Imagelist control name in ‘imageList’ property of TreeView control.
4. Set the node’s ImageIndex and SelectedImageIndex properties. The ImageIndex property determines the image displayed for the node’s normal and expanded states, and the SelectedImageIndex property determines the image displayed for the node’s selected state.
Set the icons to nodes in code:
Set the TreeView control’s ImageList property to the existing ImageList control you wish to use, and then use this code:
[vb]
TreeView1.ImageList = ImageList1 TreeView1.SelectedNode.ImageIndex = 0 TreeView1.SelectedNode.SelectedImageIndex = 1
[C#]
TreeView1.ImageList = ImageList1; TreeView1.SelectedNode.ImageIndex = 0; TreeView1.SelectedNode.SelectedImageIndex = 1;