Click here to Skip to main content
15,923,164 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using TreeView Control and I want Data like

Category
> Sub Category
> Division

in above I got only Category and Sub Category but i didn't get value of Division

Please send me answer ASAP.
Posted

Hi Mukesh,

By Values of Nodes i suppose you are refering to the Tag property. So as Sanjay told in the NodeMouseClick event we can get the Node clicked by this statement
TreeNode tn = e.Node;

Now to get all the child nodes and there respective value(Tag). We can loop through the nodes and get there respective values.
Here's the sample code

C#
TreeNode tn = e.Node;
           string st = null;

           foreach (TreeNode t1 in tn.Nodes)
           {
               st += "Node Name:" + t1.Text + " Node Data: " + t1.Tag.ToString()+ "\n";


           }
           MessageBox.Show(st);



Hope this helps you. Incase of any confusion do let me know.
 
Share this answer
 
Hi Mukesh can you send me the exact code yuu are doing for this. May be i can help you then.
 
Share this answer
 
Comments
mukeshdepani8681 3-Feb-12 11:22am    
I have used TreeView Control in my Project like

+ Jwellerry=J <-value
+ Gold=G
+ Ring=R
+ Silver=S
+ Electronics=E
+ Computer=C
+ Desktop=D
+ Laptop=L

As per Above example.....
Category = Jwellery,Electronics
SubCategory = Gold,Silver,Computer
Division = Ring,Desktop,Laptop

And all Category,Subcategory and division have values like J,G,R,S,E etc....
And now I want all values OnSelectedNodeChange but I got only Category and SubCategory Values but didn't get Division value.....

So please help me out......
On "NodeMouseClick" event there is a TreeNodeMouseClickEventArgs object e.

for getting the Node object on which the event has fired use
"e.Node"
 
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