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.

removing multiple tree nodes

Thread ID:

Created:

Updated:

Platform:

Replies:

31020 Jun 28,2005 08:31 PM Jun 29,2005 07:14 PM Windows Forms 3
loading
Tags: Tools
Tiff
Asked On June 28, 2005 08:31 PM

Hi I set my treeview control selection mode to MultiSelectSameLevel. Now, I want to be able to delete all the selected nodes. However, I following lines of code don''t seem to work foreach(TreeNodeAdv node in treeViewAdv1.SelectedNodes) treeViewAdv1.Nodes.Remove(node); I could only delete a single selected node by using treeViewAdv1.selectedNode.remove() Also, is there a sample on how to edit the tree such as cut, copy, paste, and insert. I realized that the dragNdrop sample perform the same concept as that of cut & paste. However, I want to allow the user to cut/copy & paste multiple nodes. Any suggestions?

Administrator [Syncfusion]
Replied On June 29, 2005 05:19 PM

Hi Tiff, The reason that your Remove(node) call isn''t working is that the Nodes in TreeViewAdv are stored in a true Tree structure. So Nodes that aren''t on the top level won''t be present in the TreeViewAdv.Nodes collection. You''ll need to use the Parent property like this: foreach (TreeNodeAdv node in this.treeViewAdv1.SelectedNodes) { if (node.Parent == null) { this.treeViewAdv1.Nodes.Remove(node); } else { node.Parent.Nodes.Remove(node); } } I''m not aware of any sample that demonstrates copying, cutting, and pasting nodes, but I''ll see if I can throw one together for you. Regards, Gregory Austin Syncfusion Inc.

Administrator [Syncfusion]
Replied On June 29, 2005 06:10 PM

Hi Tiff, I need to make a correction to my previous answer. You need to call Clone() on the SelectedNodes collection, since TreeNodeAdv will modify it during the iteration. Also, I have created a KB article regarding your other question. Please take a look at it and let me know if you have any questions. TreeViewAdv: How do I cut, copy, and paste nodes? Regards, Gregory Austin Syncfusion Inc.

Tiff
Replied On June 29, 2005 07:14 PM

Hi Gregory Thanx for the tips. It''s great

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.

;