区分相似的选定节点Treeview控件 [英] distinquish similar selected nodes Treeview control

查看:61
本文介绍了区分相似的选定节点Treeview控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

休闲代码我毫无问题地输出了选定的节点:
对于GetCheck(TreeView1.Nodes)中的每个n作为TreeNode

builder.Append(n.Text)

下一个

私有函数GetCheck(ByVal节点作为TreeNodeCollection)作为列表(Of TreeNode)

Dim lN作为新列表(属于TreeNode)
对于每个n作为TreeNode在节点中
如果n.Checked,则lN.Add(n)
lN.AddRange(GetCheck(n.Nodes))
下一个

返回lN
最终功能

我的问题是,当用户单击其中一个相似节点时,该如何区分?例如,我得到了休憩节点;如果用户现在单击第二个500节点,我的输出是500,我想要的是类似500second的内容,因此我知道它是第二个500节点.感谢您的帮助.

300
a
500
a
b
500
a
b
500
a
b
500
a
b
800
a

The fallowing code I output the selected nodes with no problem:
For Each n As TreeNode In GetCheck(TreeView1.Nodes)

builder.Append(n.Text)

Next

Private Function GetCheck(ByVal node As TreeNodeCollection) As List(Of TreeNode)

Dim lN As New List(Of TreeNode)
For Each n As TreeNode In node
If n.Checked Then lN.Add(n)
lN.AddRange(GetCheck(n.Nodes))
Next

Return lN
End Function

My question is how can I distinguish similar nodes when a user clicks on one of them? For example I got the fallowing nodes; if a user click on the second 500 right now my output is 500 what I want is something like 500second so I know it was the second 500 node. Appreciate your help.

300
a
500
a
b
500
a
b
500
a
b
500
a
b
800
a

推荐答案

您可以使用Treeview.SelectedIndex属性确切地选择哪个节点.如果您想使用其他方法,您还可以使用节点的Tag属性,也可以在每个节点上附加某种唯一的标识符.
You can use the Treeview.SelectedIndex property to find out exactly which node is selected. If you want another way you could also use the Tag property of the nodes to attach a unique identifier of some kind to each node as well.


这篇关于区分相似的选定节点Treeview控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆