The purpose of a TreeView
control is to display
information in a hierarchy. A TreeView
is made up of
nodes that are related to each other in some way. Users can look at information,
or objects, presented in a TreeView
control and quickly
determine how those objects are bound together.
Figure 4.4 shows a good example of TreeView in
the Windows Explorer. The left side of Explorer shows information about drives
in a hierarchical layout. Explorer starts its tree with a node called Desktop.
From there you can see several nodes indented below the Desktop node. The indentation
and the lines connecting nodes show that the My Computer node is a child of the
Desktop node. My Computer also has children—the A: drive, C: drive, and
so on. Children of the same parent are often referred to as siblings. The A: drive
and B: drive, for example, both have My Computer as a parent and are called siblings.
FIGURE 4.4 - Windows Explorer as an example of a TreeView
The TreeView control is available as part of the
Common Controls component in Visual Basic. You can use the
TreeView anytime that you need to display data to a user as a hierarchy.
Treeview Control topics