removing multiple tree nodes

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?

3 Replies

AD Administrator Syncfusion Team 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.


AD Administrator Syncfusion Team 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.


TI Tiff June 29, 2005 11:14 PM UTC

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

Loader.
Up arrow icon