Take the 2-minute tour ×

I create a treeview with several nodes in a WinForms application. I want to add a node to one of this nodes (to a child node).

How do I can do this? Thanks.

share|improve this question
add comment

3 Answers

up vote 2 down vote accepted

Every Node in treeview(winforms) is having a collection of Nodes so if you got to the node reference than just adding a new node under its collection will do the job

TreeNode node = treeView.SelectedNode;
node.Nodes.Add(new TreeNode());
share|improve this answer
+1 This is an excellent answer. –  Cody Gray Dec 6 '10 at 15:18
add comment
   foreach(Customer customer2 in customerArray)

      foreach(Order order1 in customer2.CustomerOrders)

Entire sample on MSDN...

share|improve this answer
add comment

By simply using the Add method of the Node collection of a TreeNode


treeNode.Nodes.Add(new TreeNode("Node Name"));
share|improve this answer
add comment

Your Answer


