开发者

How do I use TreeView with my Tree Datastructure? C# .NET

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜