views:

18

answers:

1

the actual procees of my work is initially i will have a root node for a treeview. If i right click on that i will have a context menu with some options. If i select add new from that i will add a text file as child node to the root node. This works fine . After adding that text file i would like to add a child node under that text file..

The over all flow will be

Initially when page loads my treeview will be with a single rootnode

ACH

If i add a text file i would like to show my treeview as follows

ACH

 |-> some.txt

|->A( Child for some.txt)

   |->B(child for  A) 

       |->C(Child for B)

Up to A i was succeded but i do not know how to add the remaining also i would like to set image index for the custom child nodes added

+2  A: 

You have to keep a reference to the node A and call Add on its Nodes property:

TreeNode nodeA = nodeACH.Nodes.Add("A");

TreeNode nodeB = node1.Nodes.Add("A");

TreeNode nodeC = node1.Nodes.Add("B");
Mike
Hey Thanks a lot
Dorababu
The image is getting changed how to set this
Dorababu
You have to set the ImageList property on your Treeview, and set for each node its ImageIndex property to reference the image
Mike
I set the property but initially it's loading the default one and when i click on the ndoe the image is getting changed
Dorababu
You will find here all the infos you need about the TreeNode class http://msdn.microsoft.com/en-us/library/system.windows.forms.treenode.aspxYou have to set the SelectedImageIndex property to define which image you want to display when the node is seledted
Mike