How to add a child node to a specific node in treeview? Say I have “Item1” in treeview already, how do I add “SubItem1” to “Item1” as it’s child node?
I know its probably really simple, but i tried lots of stuff, i just cant get it working.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Adding child node to parent (non-selected)
First use
Find()to get a reference to the parent node. Then add it using the same technique as the other sections below.Adding nodes programmatically
If you want to add the child nodes to a particluar parent node, the idea is to add the child nodes to their parent node by using the
parent.node.add()method.You can create any number of child like this.
For example if you want to have a scenario like:
Then you could do this:
More reading/examples
This page has a good example you can run to dynamically add child nodes to the tree. They do it on a button, which they’ve hooked up like this:
http://www.codeproject.com/Articles/11830/The-Basic-Operations-on-using-the-TreeView-Control