I have a Tree and load it recursively into my T开发者_运维技巧reeView on my form. The problem is, I do not know how to find out which object in my Tree that I am selected on when I select a node in my TreeView. Any ideas?
You can set the TreeNode
's Tag
property to the corresponding instance from your object model.
The TreeView
nodes (TreeNodes
) have properties like Level
, Tag
, Text
etc. The Level
property lets you identify in which level is your TreeNode
in the TreeView
and the Tag
and Text
properties may let you identify your node uniquely. You may also add same kind of properties to your Tree too and thus you may compare them relevantly and do the conversion you require...
Hope this helps...
If you have a unique id for each record you can assign that id as the TreeNode.Name. TreeNode.Tag is another option.
精彩评论