How to Select all the Nodes in a TreeViewAdv Control
1 Oct 2018 / 1 minute to read
You could select all the nodes in the TreeViewAdv control by recursively traversing through all the child nodes under each of the parent nodes at the top level as shown in the code below.
// Checking for all the root nodes in the tree.
foreach (TreeNodeAdv node in this.treeViewAdv1.Root.Nodes)
{
this.treeViewAdv1.SelectedNodes.Add(node);
TreeNodeAdv lastNode = node.LastNode;
while (lastNode != null)
{
// The selection is extended to the last node of the tree.
this.treeViewAdv1.ExtendSelectionTo(lastNode);
lastNode = lastNode.LastNode;
}
}
Dim node As TreeNodeAdv
' Checking for all the root nodes in the tree.
For Each node In Me.treeViewAdv1.Root.Nodes
Me.treeViewAdv1.SelectedNodes.Add(node)
Dim lastNode As TreeNodeAdv = node.LastNode
While Not (lastNode Is Nothing)
' The selection is extended to the last node of the tree.
Me.treeViewAdv1.ExtendSelectionTo(lastNode)
lastNode = lastNode.LastNode
End While
Next node
Was this page helpful?
Yes
No
Thank you for your feedback!
Thank you for your feedback and comments. We will rectify this as soon as possible!
An unknown error has occurred. Please try again.
Help us improve this page