问题
I have few comboboxes. I initialize their datasources through binding sources (I use EF6). My Combobox Tasks looks like this:
So, when I set AutoCompleteMode property to Suggested, the auto complete doesn't work. The weird thing, is that I have two another comboboxes, with (I would say) the exact same setup, and they work...The autocompletion works on them.
How to debug this?
回答1:
To set up a ComboBox
that automatically completes the user's input string, we need to configure 3 different properties. A description from the Docs:
Use the
AutoCompleteCustomSource
,AutoCompleteMode
, andAutoCompleteSource
properties to create aComboBox
that automatically completes input strings by comparing the prefix being entered to the prefixes of all strings in a maintained source
AutoCompleteCustomSource: the specialized collection of items that provides the source of the Autocomplete strings.
AutoCompleteMode: defines how the input auto-completion is performed.
AutoCompleteSource: specifies which is the source of the completion functionality.
The latter could be the FileSystem
, using the Files or Directories lists in a defined path, the RecentUsedItems
, HistoryList
URLs or, as in this case, AutoCompleteSource.CustomSource, indicating that the source list of items for the completion is provided by an AutoCompleteStringCollection which can be specified assigning the AutoCompleteCustomSource
property a AutoCompleteStringCollection
or another compatible source (a List
for example, since this collection implements the IEnumerable
and IList
interfaces).
来源:https://stackoverflow.com/questions/53248898/setting-autocompletemode-to-suggest-doesnt-have-an-effect