Tree View Control

The TreeView control allows you to display a list of objects in a hierarchical manner. Each object in the TreeView control represents an instance of the TreeNode class, which contains information about the location of the node within the TreeView control. Nodes containing child nodes in the TreeView control can be collapsed and expanded. Figure 3-5 shows a TreeView control in a form.

Figure 3-5 The TreeView control

The primary property of the TreeView control is the Nodes property. This property contains the collection of TreeNodes that comprise the root objects in the TreeView. Each individual TreeNode object contains its own collection of TreeNodes that represent child nodes of that node. Table 3-7 describes some of the important properties of the TreeNode class.

Table 3-7 Important Properties of the TreeNode Class




Returns the first node in the current group of child nodes.


Returns the last node in the current group of child nodes.


Returns the next sibling tree node.


Returns the next visible node.


Returns the collection of child nodes belonging to this node.


Returns the parent node of the current node. If the current node is a root node in the TreeView, accessing this property will throw a NullReferenceException.


Returns the previous node.


Returns the previous visible node.


Returns a reference to the TreeView control that the TreeNode is contained in.

Was this article helpful?

0 0

Post a comment