Solved

Treeview node ID

Posted on 2008-10-06
4
613 Views
Last Modified: 2013-12-17
I have a treeview with two levels.  The user clicks a check box that selects the name in the last node.  I move the text from this node into a text box.  Well, I also want to capture the id and put it into an array.  How do I do this?
foreach (DataRow dr in tissueLevel.Rows)
                    {
                        if (!treeView1.Nodes.ContainsKey(dr["tg_id"].ToString()))
                        {
                            treeView1.Nodes.Add(dr["tg_id"].ToString(), dr["name"].ToString());
                        }
                    }
                    foreach (DataRow dr in tissueLevel.Rows)
                    {
                        TreeNode[] nodes = treeView1.Nodes.Find(dr["tg_id"].ToString(), true);
                        if (nodes.Length > 0)
                        {
                            TreeNode node = nodes[0];
                            if (!node.Nodes.ContainsKey(dr["auto_id"].ToString()))
                            {
                                node.Nodes.Add(dr["auto_id"].ToString(), dr["label"].ToString());
                            }
                        }

Open in new window

0
Comment
Question by:MichelleLacy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
Priest04 earned 500 total points
ID: 22652309
Yo could save ID into TextBox Tag property.

Goran
0
 

Author Closing Comment

by:MichelleLacy
ID: 31503493
that is very logical and so obvious that I did not see it.  It helps to have another set of eyes.  Thanks so much!!!
0
 
LVL 18

Expert Comment

by:Priest04
ID: 22652875
You are welcome.

Goran
0
 

Author Comment

by:MichelleLacy
ID: 22653830
I figured out how to do it.  I tricky part was the diffference between the node text and the node name.  The text is what is displayed in the textbox, but the node name is the id that was after.  So to add to a list, it is simply  myList.Add(n2.Name.ToString())
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question