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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Scott LysleRank #49 · 31K reputationPosted Apr 25, 2008, 4:45 AM EDT
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);
}