How to Select all the Nodes in a TreeViewAdv Control

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