System.Web.UI.WebControls Namespace TreeNode Class
.NET Framework version 2.0
Returns a collection of TreeNode objects that represents the first-level child nodes of the current node in a TreeView control.
Script |
[ TreeNodeCollection variable = ] TreeNode.ChildNodes |
variable |
Returns a TreeNodeCollection that contains the first-level child nodes of the current node in a TreeView. |
The property is read only with no default value.
Use the ChildNodes collection to programmatically obtain information about each of the first-level child nodes of the current node in a TreeView control. This collection is typically used to iterate through all the child nodes, or to access a specific child node, of the current node.
The ChildNodes property can also be used to programmatically add, insert, or remove TreeNode objects in the collection. Any updates to the collection are automatically reflected in the TreeNode control after the next round trip to the server.
To access the child nodes further down the tree, use the ChildNodes property of the next-level child node to navigate down the node hierarchy.
The following example shows how to programmatically add child node objects to the ChildNodes collection of a root or parent TreeNode control.
TreeNode newNode = new TreeNode ( nodeText, nodeValue );
newNode.NavigateUrl = webPageUrl;
parentNode.ChildNodes.Add ( newNode );
Dim newNode As New TreeNode ( nodeText, nodeValue )
newNode.NavigateUrl = webPageUrl
parentNode.ChildNodes.Add ( newNode ) |
|
C# |
VB |
Show me
TreeNode Members