Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to create Binary tree in TreeView Control from List
Could not find any Logic.
My list as:
C#
List members = getAllMembers();

I tried:
C#
TreeView1.Node.Add(members.First());  //Root Node Add
//TreeNode LeftNode,RightNode;

Now i am getting how to move futher.

C#
//I know the logic for Left child is: 
if (isExists( members[currentNodeIndex * 2])
 LeftNode.Nodes.Add(members[currentNodeIndex * 2]) 

//for Right child
if (isExists( members[(currentNodeIndex * 2) + 1])
 LeftNode.Nodes.Add(members[currentNodeIndex * 2])

I have record of more than 2000 members. I want to display all in hierarichal order in treeview. Could not find proper logic. Please help.
Posted
Updated 12-May-10 23:02pm
v2

1 solution

I do not have any idea on how to do this as I am having difficulty in visualizing a TreeView displaying a BinaryTree. It would end up being very, very wide for any tree with a depth greater than about 3.

However I recently bookmarked this[^] for later investigation and offer it in the hope that it might be of use to you.

Good luck! :)
 
Share this answer
 

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