This example adds several Node objects to a TreeView control. When you click the form, the Expanded property for each Node is set to True. To try the example, place a TreeView control on a form and paste the code into the form's Declarations section. Run the example, and click the form to expand all the Node objects.
Private Sub Form_Load()
Dim nodX As Node
Dim i as Integer
TreeView1.BorderStyle = vbFixedSingle ' Show border.
' Create a root node.
Set nodX = TreeView1.Nodes.Add(,,"root","Root")
For i = 1 to 5 ' Add 5 child nodes.
Set nodX = TreeView1.Nodes.Add(i,tvwChild,,"Node " & CStr(i))
Next i
End Sub
Private Sub Form_Click()
Dim I as Integer
For I = 1 to TreeView1.Nodes.Count
' Expand all nodes.
TreeView1.Nodes(i).Expanded = True
Next I
End Sub