Microsoft & .NETVisual BasicVB Coding Tip: Treeview - The Basics

VB Coding Tip: Treeview – The Basics content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

The basics of using the treeview control.

Private Sub Form_Load() 
'Declare Variables 
Dim mNode As Node 
Dim i As Integer 
'Populate the list box 
List1.AddItem "Node 1" 
List1.AddItem "Node 2" 
List1.AddItem "Node 3" 
'Add the primary node 
Set mNode = Treeview1.Nodes.Add() 
mNode.text = "Primary Node" 
'Add the nodes from the list box 
For i = 0 To List1.ListCount -1 
 Set mNode = Treeview1.Nodes.Add(1, tvwChild) 
 mNode.Text = List1.List(i) 
Next i 
End Sub

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Latest Posts

Related Stories