Solved

Treeview node ID

Posted on 2008-10-06
4
578 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
A short film showing how OnPage and Connectwise integration works.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

919 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now