Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TreeView TreeNodeCollection Key

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.

like image 733
Maxim Gershkovich Avatar asked Dec 08 '10 08:12

Maxim Gershkovich


People also ask

What is TreeView control in C#?

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.

What is TreeView control?

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.


1 Answers

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.

like image 149
William Avatar answered Oct 06 '22 04:10

William