Things You'll Need:
- VB.net
-
Step 1
Open VB.net
-
Step 2
New ProjectCreate a new VB.net project by selecting "File" then selecting "New Project".
-
Step 3
ButtonAdd a button to the form. This button will be used to add the node at runtime. The underlying code will be addressed in a later step in this how to article.
-
Step 4
TreeviewAdd the treeview control to your form. This is the control you will need to add nodes to.
-
Step 5
Click eventDouble click on the button control to bring up the button's click event.
-
Step 6
CodeIn the click event we will add nodes to our treeview control with this code:
TreeView1.Nodes.Add("Item " & TreeView1.Nodes.Count)
This code says to add a node and name it "Item" and then assign the name with the number of items in the control. This way each item has a different name. -
Step 7
Run the program by pressing the "F5" key on your keyboard.
-
Step 8
Final ResultsClick the button a few times to see the nodes added.











