When I was trying to copy node from one treeview to another, I got a strange error: “Cannot add or insert the item ‘node1’ in more than one place. You must first remove it from its current location or clone it.
Parameter name: node”
After searching for a while, I couldn’t find any solution. I tried this in VB.NET and had the same error
Code example:
TreeNode node1 = new TreeNode("node1");
node1.Name = "node1";
treeView1.Nodes.Add(node1);
TreeNode nd = treeView1.Nodes[0];
treeView2.Nodes.Add(nd);
Are there any solutions for this?
Thanks everyone! This works now!
yes ,use deep copy
change your code to this