TreeNode
Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio
| Exam 70-526 Preparation Guide: Configure the layout and functionality of a Windows Form to display a list of items |
Contents |
Each node in a TreeView is an instance of the TreeNode class. A TreeNode contains information about its location within a TreeView and any child nodes that it may contain.
[edit]
Inheritance hierarchy
System.Object
System.MarshalByRefObject
System.Windows.Forms.TreeNode
[edit]
Useful properties
-
FirstNode- Gets the first child tree node in the tree node collection.
-
-
ImageIndex- Gets or sets the image-list index value of the default image that is displayed by the tree nodes. By default this value is equal toTreeView.ImageIndex. To specify another image index, you must set this property explicitly.
-
-
LastNode- Gets the last child tree node.
-
-
NextNode- Gets the next sibling tree node.
-
-
NextVisibleNode- Gets the next visible tree node.
-
-
Nodes- Gets the collection ofTreeNodeobjects assigned to the current tree node.
-
-
Parent- Gets the parent tree node of the current tree node. If the current node is a root node in theTreeView, accessing this property will throw aNullReferenceException.
-
-
PrevNode- Gets the previous sibling tree node.
-
-
PrevVisibleNode- Gets the previous visible tree node.
-
-
SelectedImageIndex- Defines the image list index value of the image that is displayed when the tree node is in the selected state. By default this value is equal toTreeView.SelectedImageIndex. To specify another image index, you must set this property explicitly.
-
-
Text- Defines the text displayed in the label of the tree node.
-
-
TreeView- Gets the parent tree view that the tree node is assigned to.
-
[edit]
Expanding or Collapsing nodes manually
At some point you may wish to expand or collapse a node within a TreeView without intervention form the user. This is done through the use of two methods within the TreeNode class.
To expand a node, call the method Expand as follows:
Node1.Expand();
To collapse a node, call the method Collapse as follows:
Node1.Collapse();
[edit]
MSDN references
|
© 2007-2008 Mike Kitchen


