It is my understanding that the NAME of a node in a TreeView is the same as the KEY.
If so, I don't understand why ContainsKey
(fyi: ContainsKey
requires string) does not return the correct result:
MessageBox.Show(tv_Projects.SelectedNode.Name); //This shows "1"
MessageBox.Show(tv_Projects.Nodes.ContainsKey("1").ToString()); //This shows "false"
Why does the second message box say "false" when the key "1" clearly exists, as stated in the first message box. This is how I create the node.
TreeNode Approved;
TreeNode Approved_Open;
Approved = TV_Project.Nodes.Add("Approved Projects");
Approved_Open = Approved.Nodes.Add("Open");
Approved_Open.Nodes.Add(dr["Project ID"].ToString(), dr["Project Name"].ToString());
Project ID
and Project Name
are pulled from a database. Project ID
returns 1 as proven in the first message box.
Any help is greatly appreciated. Thanks!