Sunday, September 14, 2008

How to add images for a Node in TreeView control

To add images in a Node for treeview control

1- Add new ImageList component to your form
2- Add bitmap images (normally 16 x 16) to your project (Project->Add new Item).
3- Select your ImageList and poulate Images property with each o images (Images Collection Editor form).
4- Set ImageList property of your TreeView control to your ImageList component.
5- Add nodes to your treeview control with using ImageIndex, Image Index starts from 0
Example:
myTreeNode = new TreeNode(myMovie.movieName, 0, 0);
treeViewMovies.Nodes.Add(myTreeNode);
for next image you can use 1 and so .
Look at "TreeNode.ImageIndex Property" in MSDN

Share/Bookmark

No comments: