Results 1 to 3 of 3

Thread: how to make a datatable without case sensitive and show the result with only 4-5 char

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2016
    Posts
    6

    Post how to make a datatable without case sensitive and show the result with only 4-5 char

    I've a filter, a datatable linked with a listbox and if statements, now i need to know, how can i say to program, when user search on datatable to don't care if a word is written with an upcase or lowcase character, and show the result when a few words at least is written into texbox? (like 4 or 5)

    This is the code:

    Code:
     Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
            Dim dvtest As New DataView
            dvtest = dttest.DefaultView
            dvtest.RowFilter = "test Like '%" + TextBox1.Text + "%'"
            If dttest.Rows.Count >0 <2 Then
                For counter As Integer = 0 To dttest.Rows.Count < 3
                    If dttest.Rows(0).Item(0).ToString = TextBox1.Text Then
    .....
    End If
    UPDATE
    I resolved it with this code, wasn't very hard sorry:
    Code:
    TextBox1.Text = Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(TextBox1.Text)
            TextBox1.SelectionStart = TextBox1.TextLength
    Now i want to know, how i can show the result of an if statement with at least 2 or 5 words without trim the left text ? I tried with this code:

    Code:
    dttest.Rows(0).Item(0).ToString.ToLower.StartsWith(TextBox1.Text.ToLower)
    But with this, the Item of that row disappear, and only with a letter(wrong one), show the picture of that if(but i like the user just put 3 or 4 words for show the result of the if (the same of that row value without trim the others, to show the picture)
    Last edited by axel48; Mar 10th, 2016 at 05:17 PM.

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

    Re: how to make a datatable without case sensitive and show the result with only 4-5

    The String.Equals, String.StartsWith and String.EndsWith methods are all overloaded and allow you to specify whether the comparison should be case-sensitive or case-insensitive. You never need to change the case of anything in order to compare.

  3. #3
    PowerPoster
    Join Date
    Oct 2010
    Posts
    2,141

    Re: how to make a datatable without case sensitive and show the result with only 4-5

    For the originally asked question see: DataTable.CaseSensitive Property

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