You can't add a TreeNodeCollection
to a Node. You must loop through the TreeNodeCollection
and add the nodes individually like so:
For j As Integer = 0 To TreeNodes.Count - 1
n.Nodes.Add(TreeNodes(j).Clone())
Next
Notice I used .Clone()
. This is due to the insertion of an already existing node. You can't do that, you must either delete the existing one or clone it. In my case, I had to clone it.