I am trying to copy the entire tree (exactly all nodes) of a treeview (completely) to another treeview using this code:
TreeNodeCollection myTreeNode
Using the node.Clone() function works as well...
foreach (TreeNode node in treeViewSource.Nodes)
{
treeViewTarget.Nodes.Add((TreeNode)node.Clone());
}
Adding a root node will help ensure the "PlusMinus" functionality is viewable.
TreeNode rootNode = new TreeNode("Root Node");
treeViewTarget.Nodes.Add(rootNode);
foreach (TreeNode node in treeViewSource.Nodes)
{
rootNode.Nodes.Add((TreeNode)node.Clone());
}
rootNode.Expand();