#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2005
    Location
    Iran
    Posts
    35
    Rep Power
    10

    How to filter Combobox items on "OnChangeEvent"?


    Hi folks:

    I want to know how can I omit combox's items based on entered
    value in edit section of combobox.assume that I have a combobox with these items:

    1.Bob
    2.David
    3.Dan
    4.Frank
    5.Jack
    6.John
    7.Mary
    8.Marley
    9.Sara
    10.Susan

    I want that when I type for example Letter M,combobox shows
    just those items which starts with letter M...

    How can I do this?

    Thanks in advance.
  2. #2
  3. Coding is my mission
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2004
    Location
    Willebroek, Belgium
    Posts
    340
    Rep Power
    42
    First clear your list and build it up again ...

    But where do you get your data from?
  4. #3
  5. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,625
    Rep Power
    4247
    Personally, I think this is a bad approach. What if I make a typo? Now I can't see items beginning with another letter. There is a better way around this issue. The default combo box component already does something very nice. When you type the first letter, it scrolls down to the first item that starts with that letter. When you type the second letter, it scrolls down to the first item that begins with those two letters. All you have to do is ensure that the list of items is sorted in alphabetical order.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2008
    Posts
    1
    Rep Power
    0

    filter combobox when typing... here is the code


    just add this. I put it in the page load

    combobox1.AutoCompleteMode = AutoCompleteMode.Suggest
    combobox1.AutoCompleteSource = AutoCompleteSource.ListItems

IMN logo majestic logo threadwatch logo seochat tools logo