beginners tutorial - Learn VB6
VB6 tutorial - Learn Advanced VB6
Analysis - System analysis and Design tutorial for Software Engineering
You are here: Visual
Basic > Advanced VB6 tutorial
> Chapter 4
TreeView Properties of TreeView Control in Visual Basic 6
Numerous properties for the TreeView
for Node objects define the appearance of the tree and give access to nodes within
the tree. You can use many of these properties to navigate through a
, as follows:
Child Returns a reference to the first child of a node. The
Child property can be used to set a reference to a node:
Dim objNode as Node
objNode = TreeView1.Nodes(1).Child
This sets objNode equal to the first child of the node
with index 1. Operations can also be performed directly on the reference to the
= "This is the first child."
This changes the text for the first child
node of node 1.
FirstSibling Returns a reference to the first sibling of
the specified node. FirstSibling is a node at the same
level as the specified node.
LastSibling Returns a reference to the last sibling of the
specified node. LastSibling is a node at the same level
as the specified node.
Parent Returns a reference
to the parent of the specified node.
Next Identifies the node
immediately following the specified node
in the hierarchy.
Previous Identifies the
node immediately preceding the specified
node in the hierarchy.
Root Provides the root
node, or top-level node, in the tree for the
SelectedItem Returns a reference to the node currently selected
in the TreeView control.
Nodes Returns a reference to the entire Nodes Collection
for the TreeView.
You can also use the following additional properties
to control the behavior and appearance of the
Children Returns the total number of child nodes for a given
Selected A True or False value indicating whether a particular
node is selected.
Expanded A True or False value indicating whether a particular
node is expanded (that is, its child nodes are visible).
FullPath Returns a string value depicting the entire path
from the root to the current node. The full path is made up of the concatenated
text values of all the nodes from the root, separated by the character specified
by PathSeparator property.
PathSeparator Identifies the character used as a separator
in the FullPath property.
LineStyle Determines the appearance of the lines that connect
nodes in a tree. LineStyle can have two values 0 (tvwTreeLines)
and 1 (tvwRootLines). If LineStyle
is 0, there will be lines connecting parents to children and children to
each other. If LineStyle is 1, there will also be lines
connecting the root nodes.
Sorted A True or False value for the
TreeView. If Sorted is True, the root nodes will be sorted alphabetically
by the Text property of each node.
Child nodes will also be sorted alphabetically within each parent. If
Sorted is False, the nodes in the TreeView will
not be sorted.
When the Sorted property is set to True, the nodes
that already exist in the TreeView will be sorted.
If any additional nodes are added, they will not be sorted into the existing nodes.
The Sorted property will have to be set to True again for these new nodes to appear
in sorted order.
Treeview Control topics
<< Previous | Contents
| Next >>