If we have to more than 1 treeview in one forms...
How do we do it in c#. DO we repeat the same code thrice....or can we populate treenodes for all the treeviews at once...If so how can we do it?
Thanks in advance
If we have to more than 1 treeview in one forms...
How do we do it in c#. DO we repeat the same code thrice....or can we populate treenodes for all the treeviews at once...If so how can we do it?
Thanks in advance
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Scott LyslePosted Apr 25, 2008, 8:45 AM
TreeNode tn1 = new TreeNode("Animals");
TreeNode tn2 = new TreeNode("Plants");
TreeNode tn3 = new TreeNode("Minerals");
treeView1.Nodes.Add(tn1);
treeView1.Nodes.Add(tn2);
treeView1.Nodes.Add(tn3);
foreach(TreeNode tn in treeView1.Nodes)
{
TreeNode tnNew = (TreeNode)tn.Clone();
treeView2.Nodes.Add(tnNew);
TreeNode tnNew2 = (TreeNode) tn.Clone();
treeView3.Nodes.Add(tnNew2);
}