This example adds several Node objects to a TreeView control. After a Node is selected, click the form to begin editing it. To try the example, place a TreeView control on a form, and paste the code into the form's Declarations section. Run the example, select a Node, and click the form.
Private Sub Form_Load
Dim nodX As Node
Set nodX = TreeView1.Nodes.Add(,,,"Da Vinci") ' Root
Set nodX = TreeView1.Nodes.Add(1,tvwChild,,"Titian")
Set nodX = TreeView1.Nodes.Add(1,tvwChild,,"Rembrandt")
Set nodX = TreeView1.Nodes.Add(1,tvwChild,,"Goya")
Set nodX = TreeView1.Nodes.Add(1,tvwChild,,"David")
nodX.EnsureVisible ' Expand tree to see all nodes.
End Sub
Private Sub Form_Click()
' If selected Node isn't the Root node then allow edits.
If TreeView1.SelectedItem.Index <> 1 Then
TreeView1.StartLabelEdit
End If
End Sub