Results 1 to 3 of 3

Thread: Autocomplete combobox

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Autocomplete combobox

    You would have thought this would have been a standard feature of the combobox, but MS decided to make it hard on us once again.

    I got some code to autocomplete a combobox when typing, but it does not limit to the dropdown list. Does anyone have some code that does this? if not I am going to try to work the code I have to do so, and I will post it once I am done

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Well, I solved this in web applications fairly easily.

    Basically you construct a regex of the text the user has typed, and it can match the first found item, and autopopulate what it thinks is what the user wants .

    So if you press 'S', the regex may find Sunshine as a match, because it only checks the available list items for the length of the text the user has typed. Since Sunshine has an S, it will put Sunshine in the textbox, and then highlight 'unshine'. The highlighted part is the text the user didn't type, but the text you autocompleted. This is necessary so your code knows the difference between what the user typed, and what it autocompleted.

    So if the user now press 'u', the process continues (you take the userinput, indentified as the text up to the selection point and search again).

    If the user types something that doesn't match any item, i simply consumed the event, disallowing the input.

    Now, I HAD to do it that way for web apps, there may be an easy way in Forms applications...

  3. #3
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    Coincidentally, I read this earlier today at VBCity.

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