Basically Tree View contains two things, first one is root node and second one is child node. If you want to create root node in the Tree View then use Tree Node class. Now in this example, we want to create a child node inside the existing root node. So first to create the root node, Follow these instruction to create the root node inside the tree view control.
- Add Tree View control in the design form.
- Add Root Node in it by right click on Control.
3. Add one Button control and one TextBox control in the design form.
4. Raise the Button Click event, Copy this code and paste into Button_Click event handler
private void button1_Click(object sender, EventArgs e)
TreeNode node = treeView1.SelectedNode;