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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

removing multiple tree nodes

Thread ID:





31020 Jun 29,2005 12:31 AM UTC Jun 29,2005 11:14 PM UTC WinForms 3
Tags: Tools
Asked On June 29, 2005 12:31 AM UTC

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 09:19 PM UTC

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 10:10 PM UTC

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.

Replied On June 29, 2005 11:14 PM UTC

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


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon