We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Pragmatically select children nodes when parent is selected

Thread ID:

Created:

Updated:

Platform:

Replies:

25903 Mar 9,2005 10:03 AM Mar 10,2005 01:41 PM Windows Forms 1
loading
Tags: Tools
Gurbhej Dhillon
Asked On March 9, 2005 10:03 AM

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.

Administrator [Syncfusion]
Replied On March 10, 2005 01:41 PM

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.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;