Hello everybody,
For the last 2 days im trying to deal with a treeview. What i want to do is to copy the structure from one tree to another. I know there are other ways to do this, but the way i want is to iterate through any node-of any depth-. Im using Telerik's GridView. The code below is the work that i've done so far, but when i run it it throws an Exception saying:"The collection has changed. The iteration may not be executed".
Im first calling the CopyTree() function:
public void CopyTree(RadTreeView trv)
{
NodesArr = new ArrayList();
foreach (RadTreeNode n in trv.Nodes)
{
DoTreeWork(n);
}
foreach (RadTreeNode node in NodesArr)
{
tv2.Nodes.Add(node);
}
}
And then the DoTreeWork():
public void DoTreeWork(RadTreeNode node)
{
RadTreeNode n = node;
RadTreeNode temp = new RadTreeNode(node.Text);
temp.Name = node.Name;
foreach(RadTreeNode child in n.Nodes) ----------> The Exception is thrown.
{
temp.Nodes.Add(child);
DoTreeWork(child);
}
tv2.Nodes.Add(temp);
}
I need an helping hand as soon as possible, because i need to continue with my project.
Thanks in advance,