Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Autocomplete TextBox no find other words in string

Autocomplete TextBox no find other words in string

Scheduled Pinned Locked Moved C#
regexquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    juliogyn
    wrote on last edited by
    #1

    I have this code for autocomplete:

    foreach(string match in myList){
    if( !string.IsNullOrEmpty(text_box1) ){

    if( match.StartsWith(text_box1.ToString(),
    StringComparison.CurrentCultureIgnoreCase) ){

        MessageBox.Show(match);
      }
    

    }

    }

    In String "The follow me", case find "the", the string is show me. But case find "follow" or "Follow", is not show. I'm tried with Contains but not solved. What can i do ?

    A 1 Reply Last reply
    0
    • J juliogyn

      I have this code for autocomplete:

      foreach(string match in myList){
      if( !string.IsNullOrEmpty(text_box1) ){

      if( match.StartsWith(text_box1.ToString(),
      StringComparison.CurrentCultureIgnoreCase) ){

          MessageBox.Show(match);
        }
      

      }

      }

      In String "The follow me", case find "the", the string is show me. But case find "follow" or "Follow", is not show. I'm tried with Contains but not solved. What can i do ?

      A Offline
      A Offline
      Abhinav S
      wrote on last edited by
      #2

      You are using StartsWith. If you look for "The follow", you will find the string output. What did you try with Contains?

      Apps - Color Analyzer | Arctic | XKCD | Sound Meter | Speed Dial

      J 1 Reply Last reply
      0
      • A Abhinav S

        You are using StartsWith. If you look for "The follow", you will find the string output. What did you try with Contains?

        Apps - Color Analyzer | Arctic | XKCD | Sound Meter | Speed Dial

        J Offline
        J Offline
        juliogyn
        wrote on last edited by
        #3

        With Contains, when find "follow" is show the complete string. But i try with "the fol" no show more, and "the Follow", example, to not show.

        A 1 Reply Last reply
        0
        • J juliogyn

          With Contains, when find "follow" is show the complete string. But i try with "the fol" no show more, and "the Follow", example, to not show.

          A Offline
          A Offline
          Abhinav S
          wrote on last edited by
          #4

          Try using IndexOf - http://msdn.microsoft.com/en-us/library/system.string.indexof%28v=vs.110%29.aspx[^].

          Apps - Color Analyzer | Arctic | XKCD | Sound Meter | Speed Dial

          J 1 Reply Last reply
          0
          • A Abhinav S

            Try using IndexOf - http://msdn.microsoft.com/en-us/library/system.string.indexof%28v=vs.110%29.aspx[^].

            Apps - Color Analyzer | Arctic | XKCD | Sound Meter | Speed Dial

            J Offline
            J Offline
            juliogyn
            wrote on last edited by
            #5

            Solved the problem with "||":

            if( match.StartsWith(text_box1.ToString(),
            StringComparison.CurrentCultureIgnoreCase) || match.Contains(text_box1) )

            Tanks for all help

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups