Click here to Skip to main content
15,921,250 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all

i have n number of employeenames in a list let it be
1
2
3
.
.
n

I want to bind this details to my treeview1 like
1
-2
--3
.
.
---...n
How to do this.Can any one paste code for this
Thanks in Advance
Amrutha
Posted

1 solution

If you want one tree that keeps going down, just iterate over your collection and keep calling the method to add a child. No-one can paste code you can use, without seeing your code and knowing the way your data is named.
 
Share this answer
 
Comments
amritha444 3-Aug-12 4:31am    
Hi Thanks for the response i want recursive query for below pasted code

if (i == 1)
{
parentNode = new TreeNode(s);

}
else if(i==2)
{
TreeNode chilnode = new TreeNode(s);
parentNode.ChildNodes.Add(chilnode);
}
else if (i == 3)
{
TreeNode chilnode1 = new TreeNode(s);
parentNode.ChildNodes[0].ChildNodes.Add(chilnode1);
}
else if (i == 4)
{
TreeNode chilnode2 = new TreeNode(s);
parentNode.ChildNodes[0].ChildNodes[0].ChildNodes.Add(chilnode2);
}
Christian Graus 3-Aug-12 4:33am    
That's really messy. Why not pass the parent node in to your method, that's the way to make it recursive.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900