aspnet-devexpress-dot-web-dot-treeviewnode-7e7a7beb.md
Gets the collection of child nodes within the particular node and provides indexed access to them.
Namespace : DevExpress.Web
Assembly : DevExpress.Web.v25.2.dll
NuGet Package : DevExpress.Web
public TreeViewNodeCollection Nodes { get; }
Public ReadOnly Property Nodes As TreeViewNodeCollection
| Type | Description |
|---|---|
| TreeViewNodeCollection |
A TreeViewNodeCollection object representing the collection of the child nodes.
|
Use the Nodes property to access the collection of child nodes of the current node. This collection contains only the nodes at the next level. To access nodes further down the ASPxTreeView, use the Nodes property of a child node. If the Nodes property is the null reference ( Nothing in Visual Basic), the current node does not have any child nodes. A particular node can be accessed using index notation.
Note that the nodes of an ASPxTreeView’s root node can be accessed via the ASPxTreeView.Nodes property of the ASPxTreeView control.
The code below demonstrates how you can implement recursive tree traversal, to execute a specific action for each node.
protected void PerformActionOnNodesRecursive(TreeViewNodeCollection nodes, Action<TreeViewNode> action) {
foreach (TreeViewNode node in nodes) {
action(node);
if (node.Nodes.Count > 0)
PerformActionOnNodesRecursive(node.Nodes, action);
}
}
Protected Sub PerformActionOnNodesRecursive(ByVal nodes As TreeViewNodeCollection, ByVal action As Action(Of TreeViewNode))
For Each node As TreeViewNode In nodes
action(node)
If node.Nodes.Count > 0 Then
PerformActionOnNodesRecursive(node.Nodes, action)
End If
Next node
End Sub
See Also