The TreeView uses in its underlying implementation the TreeNodeCollection. The TreeNodeCollection in almost every overload of the add method asks for a key.
It also implements indexOfKey and ContainsKey yet there appears to be no way to determine the key of a node from the node itself or from any of the events you would typically use such as TreeView_AfterSelect().
Am I correct or is there in fact someway to retrieve the key from a node or event which I have overlooked? And assuming I am correct. Why on earth was it implemented in such a way? The only thing I could think of was that perhaps TreeNodeCollection.Key is deprecated? But I see no mention of this…
PS: I am aware of the TreeNode.Tag property and how it can be used to the same effect.
The TreeView control contains a hierarchy of TreeViewItem controls. It provides a way to display information in a hierarchical structure by using collapsible nodes . The top level in a tree view are root nodes that can be expanded or collapsed if the nodes have child nodes.
A tree-view control is a window that displays a hierarchical list of items, such as the headings in a document, the entries in an index, or the files and directories on a disk. Each item consists of a label and an optional bitmapped image, and each item can have a list of subitems associated with it.
Take a look here. In the remarks you'll find the following
The Name property corresponds to the key for a TreeNode in the TreeNodeCollection.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With