The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
Hi,
I need to be able to select all the children of a Node when a node has been selected. Something similar to the interactive checkbox functionality but without the checkboxes. Any suggestions. Thanks.
ADAdministrator 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.