Solved

Treeview node ID

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
SQl help with selection 14 44
comparing string in C# 3 34
C# SQL BULK INSERT CLASS 5 36
Change data in datatable 8 18
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This video discusses moving either the default database or any database to a new volume.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

762 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

18 Experts available now in Live!

Get 1:1 Help Now