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?
Pseudocode (
c#) to demonstrate an idea using LINQ Where() + List.ForEach():See
MSDNfollowing the links above forVB.NETsyntax of both methods.