Overview
Previous  Next

TreeView objects display a hierarchical tree.
Each node in the tree is of Node type and can contain other nodes.
The TreeView can show small images left of the nodes.
Working with a TreeView is done using a TreeView object and one or more Node objects.
One Node object can be used to reference different nodes each time.
Nodes added directly to the TreeView will appear as the root nodes.
The other nodes are added to nodes.
When the user selects a node the AfterSelect event is raised.
The SelectedNode property stores a reference to the selected node.
The TreeView can show a checkbox for each node.

Example:
'Add a TreeView named tv and two Nodes named node1 and node2.
Sub Globals

End Sub

Sub App_Start
      Form1.Show
      tv.New1("Form1", 5, 10, 200, 200)
      node1.New1
      node2.New1
      node1.Value = tv.AddNewNode("Parent") 'node1 references the newly created node
      for i = 1 to 5
            node1.AddNewNode("Child" & i)
      next
      node2.Value = node1.GetNode(2) 'node2 references Child3
      for i = 1 to 3
            node2.AddNewNode("GrandChildren" & i)
      next
      node1.Value = node2.GetNode (0) 'node1 references GrandChildren1
      node1.AddNewNode ("Great-Grandson")
      tv.ExpandAll      
End Sub

Sub tv_AfterSelect
      'The commented statement does the same thing as the two following lines.
      'Form1.Text = tv.SelectedText
      node1.Value = tv.SelectedNode
      Form1.Text = node1.Text
End Sub