469,613 Members | 1,267 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,613 developers. It's quick & easy.

access and modify a certain node in a tree view

ive created a certain tree view, which i want to modify (in run time)
on a certain button click.
how can i change a certain node label name and how can i change its image (assume i have images in a image list)

Mar 14 '09 #1
3 1401
3,525 Expert 2GB
Assuming your tree control is named "EventTree" this is how you make a new node
Expand|Select|Wrap|Line Numbers
  1.             TreeNode mainNode = new TreeNode();
  2.             mainNode.Name = "mainNode";
  3.             mainNode.Text = DateTime.Now.ToShortDateString();
  4.             EventTree.Nodes.Add(mainNode);
To change an existing node:
Make a new node
Find the old node
Set the old node to the new node you just made
Mar 14 '09 #2
how can i find the old one?
every node has it own index?
suppose i want to reach a certain node (a certain index) how can i do it?
Mar 14 '09 #3
3,525 Expert 2GB
Read up on the TreeView control. The experiment a little: Its the best way to learn.

A common technique is to just check each node recursively to see if it is the text you are looking for. HINT: foreach(TreeNode tn in MyTreeView.Nodes)

Visual Studio has a built in search feature under the 'Help' menu that comes in handy for finding this stuff on MSDN. And if that is too dry to read, Google will show you a lot of other Tutorials and How-To's.

Mar 14 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

8 posts views Thread by Frnak McKenney | last post: by
3 posts views Thread by Saradhi | last post: by
3 posts views Thread by Adam Honek | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.