Results 1 to 4 of 4

Thread: Why Not Accept TreeView SelectedNode based onTextBox.Text ?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2018
    Posts
    77

    Why Not Accept TreeView SelectedNode based onTextBox.Text ?

    wtihs this code I set Focus to TreeView Node.

    Code:
     Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
            
            'Expand(TextBox3.Text) '("C:\7143\Baltek")
            gotNode = False
            For Each n As TreeNode In Me.TreeView1.Nodes
                If Not gotNode Then
                    
                    selectTreeNode(n, TextBox3.Text) ' "C:\7143\Baltek")
    
                    
                End If
              
            Next
    
        End Sub

    When I try to set focus TreeViewNode based on TextBox.Text (with dont care uppercase, lowercase) then no result.

    For Excample Node Tag is "C:\7143\Baltek")

    if I enter "C:\7143\baltek") or "C:\7143\BalteK") no result, because of Upper LowerCase typing

    how can I adjust to find not with any type textbox.text.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Why Not Accept TreeView SelectedNode based onTextBox.Text ?

    Presumably you are performing a String comparison in that 'selectTreeNode' method so you need to make that comparison case-insensitive. You don't need us to tell you how to do that because you can find out in a matter of seconds by searching the web with the appropriate keywords, e.g. "vb.net case insensitive comparison".
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2018
    Posts
    77

    Re: Why Not Accept TreeView SelectedNode based onTextBox.Text ?

    Quote Originally Posted by jmcilhinney View Post
    Presumably you are performing a String comparison in that 'selectTreeNode' method so you need to make that comparison case-insensitive. You don't need us to tell you how to do that because you can find out in a matter of seconds by searching the web with the appropriate keywords, e.g. "vb.net case insensitive comparison".
    thanks for edvice but I couldnt find a solution. but same problem here

    Code:
    Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
            For Each n As TreeNode In Me.TreeView1.Nodes(0).Nodes
                If n.Text = "Users" Then
                    TreeView1.SelectedNode = n
                    TreeView1.Select()
                    TreeView1.SelectedNode.Expand()
    
                End If
            Next
        End Sub
    When Type "Users" 'With Capital "U"

    TreeView.SelectedNode is Focus On "C:\Users"

    But When I type "users" with "u"

    this time result is nothing.

    is the problem about TreeView or about the Code ?

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Why Not Accept TreeView SelectedNode based onTextBox.Text ?

    As implied earlier, it is about the code:
    Quote Originally Posted by Nicomendox View Post
    Code:
                If n.Text = "Users" Then
    That is a case sensitive comparison (ie: only "Users" will match, "users" or "USERS" etc wont), and you want a case insensitive comparison.

    Following the advice about a web search (using the text jmcilhinney provided) gives many relevant results, including this one:
    https://docs.microsoft.com/en-us/dot...ypes/comparing

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width