Articles in this section
Category / Section

How to dynamically add the node to TreeView control?

1 min read


You can add a node to TreeView programmatically, by defining and adding an object of TreeViewNode class to the TreeView control.


To add the Menu Item in Menu control, you need to do the following:

  1. Define the properties of TreeView node object, like Text, expanded with help of TreeViewNode class.
  2. Add the defined item object to the TreeView control by using the Add() method.

Refer the given code example.


TreeViewNode rootNode = new TreeViewNode();
rootNode.Text = "MailBox";
rootNode.Expanded = true;
/* tree - TreeView control is already defined in a designer page. 
Adding the new TreeViewNode item using add method.*/


Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment