Ghaleon
Ghaleon

Reputation: 1216

How to work around the ComboBox's auto complete

I'm using ComboBox with auto-complete that comes from a database table. The Append and Suggest is working perfect! And AutoCompleteSource : ListItem.

But I have a problem: when the user clicks on the arrow of the ComboBox and starts typing it starts to auto-complete normally, but if I press Enter it does not select the value I wanted.

I click on the ComboBox arrow and start typing a name and as it auto-completes the text in the ComboBox field, I hit Enter but it just jumps to the next control without setting that value to the combobox.

How do I select the desired value?

Upvotes: 0

Views: 578

Answers (1)

Mike_Matthews_II
Mike_Matthews_II

Reputation: 732

You fix this in Javascript. You need to tie into the box (probably on the key press event) and set it to keep a var pointing to the first value in the result set; and then on key press == 13 (enter), you want to set the element value to the previously stored var. It's quick and easy to code. You can make it even more fun to use by creating a custom control that wraps your other control, includes your custom JS, and extends properties such as "Required" for situations like this one.

Upvotes: 0

Related Questions