Posts Tagged ‘Node’

How to search Node in Treeview Control
  1.  Private Function search(ByVal Nod As TreeNode, ByVal StrFind As String) As TreeNode
  2.         If Nod Is Nothing Then Nod = Me.Nodes(0)
  3.         Dim tmpNod As TreeNode
  4.  
  5.         If String.Compare(Nod.Text, StrFind, True) = 0 Then
  6.             Return Nod
  7.         Else
  8.             For Each mNod As TreeNode In Nod.Nodes
  9.                 tmpNod = search(mNod, StrFind)
  10.                 If Not tmpNod Is Nothing Then
  11.                     Return tmpNod
  12.                 End If
  13.             Next
  14.         End If
  15.         Return Nothing
  16.     End Function

Usage:

  1. dim nod as TreeNode
  2.  
  3. nod = search(me.MyTreeViewControl.Nodes(0), "My search")

, ,

No Comments



SetPageWidth