按值查找 TreeView 节点
我的所有 TreeView 节点都有一个唯一的节点深度 ID。
我想在与某个值匹配的 TreeView 节点上设置 Checked=True
。
目前我正在执行以下操作:
Dim value As Integer = 57
For Each n As TreeNode In tvForces.Nodes
If n.Value = value Then n.Checked = True
Next
是否有更好的方法来查找我想要设置为 Checked=True
的节点,而不是循环遍历每个节点?
我正在寻找类似的东西:
Dim value As Integer = 57
n.FindNodesByValue(value)(0).Checked = True
有没有类似的东西我可以使用?
All my TreeView nodes have a unique ID for their Node Depth.
I want to set Checked=True
on the TreeView Node which matches a certain value.
Currently I'm doing the following:
Dim value As Integer = 57
For Each n As TreeNode In tvForces.Nodes
If n.Value = value Then n.Checked = True
Next
Is there a better way of finding the Node which I want to set as Checked=True
rather than looping through each node?
I'm looking for something like:
Dim value As Integer = 57
n.FindNodesByValue(value)(0).Checked = True
Is there anything like this that I can use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
伪代码 (
c#
) 使用 LINQWhere( ) + List.ForEach():请参阅上述链接后的
MSDN
,了解这两种方法的VB.NET
语法。Pseudocode (
c#
) to demonstrate an idea using LINQ Where() + List.ForEach():See
MSDN
following the links above forVB.NET
syntax of both methods.