简体   繁体   中英

Typing into a ComboBox in C#

I have a ComboBox in menu mode with a huge amount of names, and the user is prompted to select a particular one.

If the user wants, say, "Neil", then they first press 'n' which brings up the first name beginning with 'n': Nash, for example. Then, quickly after pressing 'n', they press 'e' which they expect will bring up all names beginning with 'ne', however this is not what happens. It brings up all the names beginning with 'e'.

Regardless how quickly the user types, if they type "neil" with the box in focus, it will bring up the names beginning with 'l'.

Is there any way to change this behaviour?

You have to set following properties:

comboBox1.AutoCompleteMode = AutoCompleteMode.Suggest;
comboBox1.AutoCompleteSource = AutoCompleteSource.HistoryList; 

and it will do like you expect.

There are some more possibilities to set to AutoCompleteSource. You will find help in MSDN.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM