tags:

views:

67

answers:

1

Hi all

The county code should match only the starting characters not the characters in between. For example, If the user types "UN", it can only list counties starting with "UN"

thanks in advance

+1  A: 

If its a TextBox you are using you want to use the TextChanged event

private void textBox_TextChanged(object sender, EventArgs e)
  {
    foreach(string County in MyCountyList)
    {
      if(County.StartsWith(textBox.Text))
      {
      //Do work (Add to list or ComboBox or whatever autocompletion you require)
      }
    }
  }

If you are using a ComboBox, don't forget to clear the list each time the user changes the text entered. Hope this helps!

ThePower
This can be done in many ways. You can also use your text input as a filter on a list (the list would contain all possible county entries) and your entered text would filter them on StartsWith() etc.
kjfletch
Hi In this am using Jquery to fetch all the counties. problem am facing is i am gettin the all the countries which contains my particular character ("U") but i want only the countries starting with "U". not from middel part
Use StartsWith as opposed to Contains, I'm not sure as how to do that when using Jquery though..
ThePower