TreeView::Nodes Property

 

Gets a collection of TreeNode objects that represents the root nodes in the TreeView control.

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

public:
[PersistenceModeAttribute(PersistenceMode::InnerProperty)]
property TreeNodeCollection^ Nodes {
	TreeNodeCollection^ get();
}

Property Value

Type: System.Web.UI.WebControls::TreeNodeCollection^

A TreeNodeCollection that contains the root nodes in the TreeView.

Use the Nodes property to get a TreeNodeCollection object that contains all the root nodes in the tree. This collection is commonly used to quickly iterate through all the root nodes, or to access a specific root node in the tree.

System_CAPS_noteNote

A typical tree structure has only one root node; however, you can add multiple root nodes to the TreeView control.

The Nodes property can also be used to manage the root nodes in the tree programmatically. You can add, insert, remove, and retrieve TreeNode objects from the collection. Any updates to the collection are automatically reflected in the TreeView control after the next round trip to the server.

To access the child nodes of a root node, use the ChildNodes property of the node. Use the ChildNodes property of each subsequent parent-level node to navigate down the node levels.

The following code example demonstrates how to use the Nodes property to traverse the tree.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top
Show: