Auto Complete List Box
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Auto Complete List Box

  1. #1
    Join Date
    Dec 2008
    Posts
    1

    Auto Complete List Box

    I have a list box which contains a list of items. Currently if you type in a character say "L" then you are taken to the first record with this character, if you then type another character say "O" (in list box you now see "LO") it takes you to the first record starting with "O".

    How can I get the list box to recognise the characters that are input and go to the record starting with all of the characters?
    Any advice is appreciated

  2. #2
    PeejAvery's Avatar
    PeejAvery is online now Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,879

    Re: Auto Complete List Box

    Since you haven't posted your code, we can't completely understand your situation.

    But...The only reason it would be doing that is if you are only passing the most recently pressed character to the AJAX call. Why don't you pass the whole value of the text input?
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Aug 2005
    Location
    Milwaukee, WI
    Posts
    55

    Re: Auto Complete List Box

    I actually coded a control like this for a web framework last year some time. I literally layered a textbox with no borders over the top of the select box control. The drop down button of the select was sticking out past the edge of the textbox. I also had a 3rd hidden textbox that contained the value I cared about when the form was submitted to the server.

    As the user typed into the textbox, I searched the list for the next match and highlighted the remaining auto-filled text so they could keep typing normally over it.

    If they select something from the dropdown, I fill in the textbox.

    This leaves it up to the user how they want to use the control. I called it an Editable Combo box. This is pretty tricky. First, there are problems with cross-browser rendering and layering, not that these ever go away. Also, this would allow the user to enter values that don't exist in the dropbox. Of course, you could write code that would validate that and not allow it.

    Good luck.
    Meddle not in the affairs of dragons, human, for thou art crunchy and taste good with ketchup.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center