There is this treeview with nodes added like so:
tree.Nodes.Add("key", "DisplayText");
tree.Nodes["key"].Nodes.Add("key2", "DisplayText2);
I want to obtain the full path of the currently selected node, but I want the path of keys not the path of display text.
If the second node is selected, the tree.FullPath property will return the following:
"DisplayText\\DisplayText2"
But this is pointless to me, what I need is
"Key\\Key2"
What is the fastest way to acquire the full key path ?
TreeNode.Name
will give you the key values. There is no such property/method to return the path containing the key values.FullPath
will give you path with display values. You can recurse to build the path with key values with something like this: