Goal:
I have a working autocomplete set for a text box. Currently, data source is SQL server.
If I type any letter within the text box, some data will suggest and append to text box.
But, how can I prevent the user to use custom text? But only use data what is suggested in the Auto Complete?
Code:
customer.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
customer.AutoCompleteSource = AutoCompleteSource.CustomSource;
customer.AutoCompleteCustomSource = autotext;
From the Microsoft docs: https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.textbox.autocompletemode?view=netcore-3.1
It looks like AutoCompleteMode is the ticket. If you set the mode to "Suggest" it "Displays the auxiliary drop-down list associated with the edit control. This drop-down is populated with one or more suggested completion strings."
There is even an example on the same webpage.
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.