TreeView Control help?

mmb

Active member
Joined
Aug 1, 2004
Messages
42
Programming Experience
1-3
I want to check whether my textbox text is similar to any Node in the TreeView control or not .

NEED HELP !! its URGENT:eek:

COde is preferred:)
 
I'm not sure what you mean by similar but,

TRY THIS!!! :

VB.NET:
Private Function FindNode(ByVal ParentNode As TreeNode, _
  ByVal SearchVal As String) As TreeNode
    Dim tmpNode As TreeNode
    If ParentNode.Text = SearchVal Then
        Return ParentNode
    Else
        Dim child As TreeNode
        For Each child In ParentNode.Nodes
            tmpNode = FindNode(child, SearchVal)
            If Not tmpNode Is Nothing Then
                Return tmpNode
            End If
        Next
    End If
    Return Nothing
End Function

Private Function FindNode(ByVal TreeView As TreeView, _
  ByVal strSearchVal As String) As TreeNode
    Dim tmpNode As TreeNode
    Dim ParentNode As TreeNode
    For Each ParentNode In TreeView1.Nodes
        tmpNode = FindNode(ParentNode, strSearchVal)
        If Not tmpNode Is Nothing Then
            Return tmpNode
        End If
    Next
End Function
 
Back
Top