AD
Administrator
Syncfusion Team
March 10, 2005 06:41 PM UTC
Hi Gurbhej,
The best way to do this is to handle the AfterSelect event and then recursively add all of the selected nodes'' children to the selection. The following code snippet demonstrates this:
private void treeViewAdv1_AfterSelect(object sender, System.EventArgs e)
{
TreeNodeAdvCollection tnc = new TreeNodeAdvCollection();
foreach (TreeNodeAdv n in this.treeViewAdv1.SelectedNodes)
{
this.AddChildren(tnc, n);
}
foreach (TreeNodeAdv n in tnc)
{
this.treeViewAdv1.SelectedNodes.Add(n);
}
}
private void AddChildren(TreeNodeAdvCollection tnc, TreeNodeAdv n)
{
foreach (TreeNodeAdv child in n.Nodes)
{
tnc.Add(child);
this.AddChildren(tnc, child);
}
}
You''ll also need to set the SelectionMode to MultiSelectAll to allow a Node and its child to be selected simultaneously.
Hope this helps.
Regards,
Gregory Austin
Syncfusion Inc.