dcsimg
Results 1 to 2 of 2

Thread: Find Text in tree view, select it and focus on it.

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2010
    Posts
    254

    Find Text in tree view, select it and focus on it.

    Hi everyone,

    I am trying to find out some solution to find text in treeview, select it and focus on it.

    I have both text and key in my code.

    This is what i tried to find using key.

    Code:
    Dim Key As String
            Key = "A 5B 1"
    
            Dim SearchNode = TreeView1.Nodes.Find(Key, True)
            If SearchNode.Count > 0 Then
                MsgBox("find")
    
                TreeView1.SelectedNode = SearchNode
                TreeView1.ExpandAll()
                TreeView1.Focus()
    
            Else
                MsgBox("not found")
            End If
    This code shows me "find" in message box, now how to select the specific node?

    Thanks
    Ladak

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    102,753

    Re: Find Text in tree view, select it and focus on it.

    Find returns a TreeNode array, not a single TreeNode. You need to get the first TreeNode from that array first, do the things you need to do to that node.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width