look4guna

Member
Joined
Oct 9, 2008
Messages
18
Programming Experience
Beginner
hi!

i want to create an treeview control which has these features.

user have to enter how many nodes he wants.

after he entered the code should generate nodes in the treeview as per the text box.


can any one help to get out this problem?

OR

can any one tell me how to create treeview and root node which has sub node.

example:

ROOTNODE
'
'--SUBNODE 1
'
'--SUBNODE 3
 
You should read the documentation for the TreeView class and related classes you may encounter, especially the TreeNode class and the TreeNodeCollection class.
I have linked to online version of main help page for Treeview class, but using your local help is much much faster and better.
 
Retrieve no of child nodes

Hi friends!

can u tell me how to retrive the child nodes under a root node.

for example , i

root node
'
'
'--subnode1
'
'--subnode2
'
'--subnode3

when i click on the root node it should retrive the result as 3


can anyone help me?
 
Doubleclick the TreeView control the default event handler AfterSelect is generated, as it happens to be this event suits you fine. With the code examples for this and other Treeview events you have seen that e.Node give you the node in question. You also know that each TreeNode has a Nodes property that contains the child nodes of this node, this property is a TreeNodeCollection. Like any other collection it has a Count property that tell you how many items it contains. Putting this information together with one "." between each part you get the final answer: e.Node.Nodes.Count
 
Thanks john!.

i solved this problem, but the idea is yours.

integer = e.node.getnodecount(true)


the above code stores the node count into an integer...
 
Great, but GetNodeCount method with True parameter also includes nodes of the full subtree, which is not what you asked. Giving False parameter will give same result as Nodes.Count.
 
how to get childnodes names of a parent node

hi friends! i have to show the names sub nodes of currently selected node?

can anyone help me?
 
iterate with For-Each of the Nodes collection:
VB.NET:
For Each child As TreeNode In node.Nodes

Next
 
Back
Top