MichelleLacy
asked on
Treeview node ID
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());
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You are welcome.
Goran
Goran
ASKER
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.ToStrin g())
ASKER