?
Solved

Treeview node ID

Posted on 2008-10-06
4
Medium Priority
?
617 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

801 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