Hi,
I want a add a tree structure to be added dynamically which would basically look like a menu structure where in i can have n number of menu's which can have n number of sub menu's which in turn may have n number sub menu's and so on. I should also be able to delete the nodes as well? Can anyone tell me how to do this? Earliest response would be greatful
Loading
Sam HobbsPosted Jan 28, 2012, 11:27 AM
Karthik AgarwalPosted Jan 30, 2012, 12:20 AM
Sam HobbsPosted Jan 28, 2012, 11:55 PM
Karthik AgarwalPosted Jan 28, 2012, 11:43 PM
Karthik AgarwalPosted Jan 28, 2012, 4:18 AM
Sam HobbsPosted Jan 28, 2012, 3:10 AM
Karthik AgarwalPosted Jan 28, 2012, 1:05 AM
Sam HobbsPosted Jan 28, 2012, 12:51 AM
The typical way to store a hierarchical structure is to have an identity column for each item and each item also has the identity of its parent. The very top item has no parent, so the identity of its parent is something that indicates there is no parent.
So for example an employee that is not a manager of any type would have as their parent the supervisor. Each supervisor would have as their parent their manager. The company president would have no parent.
In a filesystem, the root directory has no parent. Every other directory (subdirectory) would have as its parent the directory that the subdirectory is in.
Does that help? Do you need more details?
Karthik AgarwalPosted Jan 27, 2012, 11:24 PM
Sam HobbsPosted Jan 27, 2012, 4:18 PM
Part of the requirement is how to store the data; is that what you are asking about?
The otehr part is how to show the data. A TreeView is typically used for that. If you need something that the TreeView cannot do then you need to explain that better.
If you need help with both of those parts, then it would be better to create a separate thread for each one since they are so independent of each other.
Karthik AgarwalPosted Jan 27, 2012, 8:30 AM
Krishna GaradPosted Jan 27, 2012, 8:27 AM
//Create Treenode control
TreeView trcontrol=new TreeView();
//Create Head Node
TreeNode headnode1=new TreeNode();
headnode1.Text="First Head";
TreeNode headnode2=new TreeNode();
headnode2.Text="Second Head";
//Add Head Node to Treeview
trcontrol.Nodes.Add(headnode1);
trcontrol.Nodes.Add(headnode2);
//Create Child Node
TreeNode child1=new TreeNode();
child.Text="Child1";
//Add Child Node to First Head Node
headnode1.ChildNodes.Add(child1);
//Create subhild
TreeNode subchild=new TreeNode()
subChild.Text="Child Of Child";
child1.ChildNodes.Add(subchild);
like this by adding head node in that you can add no of childs as well as no of subchilds.