Posts Tagged ‘Node’
How to search Node in Treeview Control
-
Private Function search(ByVal Nod As TreeNode, ByVal StrFind As String) As TreeNode
-
If Nod Is Nothing Then Nod = Me.Nodes(0)
-
Dim tmpNod As TreeNode
-
-
If String.Compare(Nod.Text, StrFind, True) = 0 Then
-
Return Nod
-
Else
-
For Each mNod As TreeNode In Nod.Nodes
-
tmpNod = search(mNod, StrFind)
-
If Not tmpNod Is Nothing Then
-
Return tmpNod
-
End If
-
Next
-
End If
-
Return Nothing
-
End Function
Usage:
-
dim nod as TreeNode
-
-
nod = search(me.MyTreeViewControl.Nodes(0), "My search")