Search code examples
c#treeviewclone

Treeview Clone event


What I would like the following code to do is add a node and its directory structure from one tree to another when clicked, but the line of code is incorrect, and I'm not sure what I can do to fix it... What is the correct way to use node.Clone() in this situation?

I'm sure its a simple fix.

private void treeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
    tVS.Nodes.Add(e.Node.Clone());
}

Solution

  • Cast is required here

    tVS.Nodes.Add((TreeNode)e.Node.Clone());