Overview (TreeView)
Action (TreeView)
AddExistingNode (TreeView)
AfterSelect Event (TreeView)
AddImage1 (TreeView)
AddImage2 (TreeView)
AddNewNode (TreeView)
CheckBoxes (TreeView)
CollapseAll (TreeView)
Color (TreeView)
Control (TreeView)
Count (TreeView)
Enabled (TreeView)
ExpandAll P(TreeView)
FontColor (TreeView)
GetNode (TreeView)
Height (TreeView)
ImageIndex (TreeView)
ImageMode (TreeView)
ImageSize (TreeView)
Indent (TreeView)
IndexOfNode (TreeView)
InsertNode (TreeView)
Left (TreeView)
New1 (TreeView)
RemoveAllNodes (TreeView)
RemoveNode (TreeView)
RemoveNodeAt (TreeView)
SelectedImageIndex (TreeView)
SelectedNode (TreeView)
SelectedText (TreeView)
ShowLines (TreeView)
ShowPlusMinus (TreeView)
ShowRootLines (TreeView)
Top (TreeView)
Width (TreeView)
Visible (TreeView)
AddNewNode (TreeView - Node)
Checked (TreeView - Node)
Collapse (TreeView - Node)
Count (TreeView - Node)
CreateNew (TreeView - Node)
Expand (TreeView - Node)
ExpandAll (TreeView - Node)
GetNode (TreeView - Node)
ImageIndex (TreeView - Node)
IndexOfNode (TreeView - Node)
InsertNode (TreeView - Node)
IsRoot (TreeView - Node)
New1 (TreeView - Node)
Parent (TreeView - Node)
RemoveAllNodes (TreeView - Node)
RemoveNode (TreeView - Node)
RemoveNodeAt (TreeView - Node)
SelectedImageIndex (TreeView - Node)
Text Previous (TreeView - Node)
Value (TreeView - Node)
Overview (TreeView) Top
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
Action (TreeView) Top
Gets a string that specifies the cause for the last AfterSelect event.
Syntax: Action
The possible values are:
bykeyboard
bymouse
collapse
expand
unknown
Example:
Sub tv_AfterSelect
if tv.Action = "bymouse" then ...
End Sub
AddExistingNode (TreeView) Top
Adds an existing node to the TreeView object.
Syntax: AddExistingNode (treeNode As Node)
Example:
tv.AddExistingNode (node1.Value)
AfterSelect Event (TreeView) Top
Occurs when the selected node has changed.
To find the exact cause that raised this event, you can check the Action property value.
Example:
Sub tv_AfterSelect
if tv.Action = "bymouse" then ...
End Sub
AddImage1 (TreeView) Top
Adds an image to the list of images of the TreeView object.
The first image added gets the index 0.
Syntax: AddImage1 (file As String)
Example:
tv.AddImage1 (AppPath & "\smiley.gif")
AddImage2 (TreeView) Top
Adds an image to the list of images of the TreeView object.
The first image added gets the index 0.
Syntax: AddImage2 (image As Image)
Example:
tv.AddImage2 (ImageList1.Item(0))
AddNewNode (TreeView) Top
Creates a new node, adds it to the TreeView object and returns a reference to it.
Syntax: AddNewNode (text As String) As Node
Example:
Form1.Show
tv.New1("Form1", 5, 10, 200, 200)
node1.New1
node1.Value = tv.AddNewNode("Parent") 'node1 references the newly created node
CheckBoxes (TreeView) Top
Gets or sets whether to show a checkbox left of each node in the TreeView object.
Syntax: CheckBoxes
Example:
tv.CheckBoxes = true
CollapseAll (TreeView) Top
Causes all nodes to collapse.
Syntax: CollapseAll
Example:
tv.CollapseAll
Color (TreeView) Top
Gets or sets the color of the control.
Syntax: Color
Control (TreeView) Top
Returns a reference to the Treeview object.
Syntax: Control
Count (TreeView) Top
Returns the number of nodes that belong to the TreeView object (only the root nodes).
Syntax: Count
Enabled (TreeView) Top
Gets or sets whether the control is enabled.
Syntax: Enabled
ExpandAll P(TreeView) Top
Causes all nodes to expand.
Syntax: ExapndAll
Example:
tv.ExpandAll
FontColor (TreeView) Top
Gets or sets the color of the font.
Syntax: FontColor
GetNode (TreeView) Top
Returns a reference to a node in the TreeView object.
Syntax:GetNode (index As Int32) As Node
The index of the first node in the TreeView is 0.
Example:
node1.Value = tv.GetNode (0)
Height (TreeView) Top
Gets or sets the height of the control.
Syntax: Height
ImageIndex (TreeView) Top
Gets or sets the default image displayed for all the nodes.
Syntax: ImageIndex
Example:
tv.ImageSize(30,30)
tv.ImageMode = true
tv.AddImage1(AppPath & "\smiley.gif")
tv.AddImage1(AppPath & "\pic.jpg")
tv.ImageIndex = 0 'smiley.gif
tv.SelectedImageIndex = 1 'pic.jpg
ImageMode (TreeView) Top
Gets or sets whether to show images left of the nodes.
Syntax: ImageMode
Example:
tv.ImageSize(30,30)
tv.ImageMode = true
tv.AddImage1(AppPath & "\smiley.gif")
tv.AddImage1(AppPath & "\pic.jpg")
tv.ImageIndex = 0 'smiley.gif
tv.SelectedImageIndex = 1 'pic.jpg
ImageSize (TreeView) Top
Sets the size of the images shown.
Syntax: ImageSize (width As Int32, height As Int32)
Example:
tv.ImageSize(30,30)
tv.ImageMode = true
tv.AddImage1(AppPath & "\smiley.gif")
tv.AddImage1(AppPath & "\pic.jpg")
tv.ImageIndex = 0 'smiley.gif
tv.SelectedImageIndex = 1 'pic.jpg
Indent (TreeView) Top
Gets or sets the indent size between different levels in the TreeView object.
Syntax: Indent
IndexOfNode (TreeView) Top
Gets the index of a node in the TreeView.
Returns -1 if the node does not exist.
Syntax: IndexOfNode (treeNode As Node) As Int 32
Example:
if tv.IndexOfNode (node1.Value) = -1 then ...
InsertNode (TreeView) Top
Inserts a node in the specified index.
Syntax: InsertNode (index As Int32, node As Node)
index - The node will be inserted in this index.
Example:
tv.InsertNode (2, node1.Value)
Left (TreeView) Top
Gets or sets the Left property of the control.
Syntax: Left
New1 (TreeView) Top
Initializes the TreeView object and adds it to a form or a panel.
Syntax: New1 (FormName As Control, left As Int32 , top As Int32, width As Int32, height As Int32)
Example:
tv.New1("Form1", 5, 10, 200, 200)
RemoveAllNodes (TreeView) Top
Removes all nodes from the TreeView object.
Syntax: RemoveAllNodes
Example:
tv.RemoveAllNodes
RemoveNode (TreeView) Top
Removes a specific node from the TreeView.
Syntax: RemoveNode (node As Node)
Example:
tv.RemoveNode (node1.Value)
RemoveNodeAt (TreeView) Top
Removes a specific node from the TreeView object.
Syntax: RemoveNodeAt (index As Int32)
Example:
tv.RemoveNodeAt (0) 'Removes the first node
SelectedImageIndex (TreeView) Top
Gets or sets the default image displayed when a node is selected.
Syntax: SelectedImageIndex
Example:
tv.ImageSize(30,30)
tv.ImageMode = true
tv.AddImage1(AppPath & "\smiley.gif")
tv.AddImage1(AppPath & "\pic.jpg")
tv.ImageIndex = 0 'smiley.gif
tv.SelectedImageIndex = 1 'pic.jpg
SelectedNode (TreeView) Top
Gets or sets the selected node.
Syntax: SelectedNode
Example:
Sub tv_AfterSelect
node1.Value = tv.SelectedNode
Form1.Text = node1.Text
End Sub
SelectedText (TreeView) Top
Gets the text of the selected node.
Syntax: SelectedText
ShowLines (TreeView) Top
Gets or sets whether lines will appear between the nodes.
Syntax: ShowLines
Example:
tv.ShowLines = true
ShowPlusMinus (TreeView) Top
Gets or sets whether the small plus signs will appear left of the nodes.
Syntax: ShowPlusMinus
Example:
tv.ShowPlusMinus = true
ShowRootLines (TreeView) Top
Gets or sets whether lines will appear before the root nodes.
Syntax: ShowRootLines
Example:
tv.ShowRootLines = false
Top (TreeView) Top
Gets or sets the Top property of the control.
Syntax: Top
Width (TreeView) Top
Gets or sets the width of the control.
Syntax: Width
Visible (TreeView) Top
Gets or sets whether the control is visible.
Syntax: Visible
AddExistingNode (TreeView - Node)
Adds an existing node to the node.
Syntax: AddExistingNode (treeNode As Node)
Example:
node1.AddExistingNode (node2.Value)
AddNewNode (TreeView - Node) Top
Creates a new node, adds it to the current node and returns a reference to it.
Syntax: AddNewNode (text As String) As Node
Example:
node2.Value = node1.AddNewNode("folder")
Checked (TreeView - Node) Top
Gets or sets whether the node is checked.
Syntax: Checked
Example:
node1.Checked = true
Collapse (TreeView - Node) Top
Causes the current node to collapse.
Syntax: Collapse
Example:
node1.Collapse
Count (TreeView - Node) Top
Returns the number of nodes the current node contains.
Syntax: Count
Example:
for i = 0 to node2.Count-1
node1.Value = node2.GetNode(i)
node1.Checked = true
next
CreateNew (TreeView - Node) Top
Creates a new node.
Syntax: CreateNew (text As String)
Example:
node1.New1
node1.CreateNew ("some text")
Expand (TreeView - Node) Top
Expands the current node.
Syntax: Expand
Example:
node1.Expand
ExpandAll (TreeView - Node) Top
Expands all nodes under the current node.
Syntax: ExpandAll
Example:
node1.ExpandAll
GetNode (TreeView - Node) Top
Gets a reference to a node that belongs to the current node.
Syntax: GetNode (index As Int32) As Node
Example:
node2.Value = node1.GetNode (0)
ImageIndex (TreeView - Node) Top
Gets or sets the image of the current node.
Syntax: ImageIndex
Example:
node1.ImageIndex = 2 'The third image added to the TreeView
IndexOfNode (TreeView - Node) Top
Returns the index of the specified node in the current node.
If the node does not belong to the current node, it will return -1.
Syntax: IndexOfNode (node As Node) As Int32
Example:
i = node1.IndexOfNode (node2.Value)
InsertNode (TreeView - Node) Top
Inserts an existing node into the current node.
Syntax: InsertNode (index As Int32, node As Node)
Example:
node1.InsertNode (4, node2.Value)
IsRoot (TreeView - Node) Top
Checks whether the current node belongs directly to the TreeView object.
Syntax: IsRoot
Example:
If node1.IsRoot = false then node2.Value = node1.Parent
New1 (TreeView - Node) Top
Initializes the object.
Syntax: New1
Example:
node1.New1
Parent (TreeView - Node) Top
Returns a reference to the node's parent.
Syntax: Parent
Example:
If node1.IsRoot = false then node2.Value = node1.Parent
RemoveAllNodes (TreeView - Node) Top
Removes all nodes that belong to the current node.
Syntax: RemoveAllNodes
Example:
node1.RemoveAllNodes
RemoveNode (TreeView - Node) Top
Removes a specific node from the current node.
Syntax: RemoveNode (node As Node)
Example:
node1.RemoveNode (node2.Value)
RemoveNodeAt (TreeView - Node) Top
Removes a specific node from the current node.
Syntax: RemoveNodeAt (index As Int32)
index - The index of the node that will be removed.
Example:
node1.RemoveNodeAt (0) 'Removes the first node
SelectedImageIndex (TreeView - Node) Top
Gets or sets the image that will be displayed when the node is selected.
Syntax: SelectedImageIndex
Example:
node1.SelectedImage = 0
Text Previous (TreeView - Node) Top
Gets or sets the text of the node.
Syntax: Text
Example:
node1.Text = "new"
Value (TreeView - Node) Top
Gets or sets the node that this node references to.
Syntax: Value
Example:
node1.Value = tv.AddNewNode("abc")