ComboBox AutoComplete Custom Capabilities

后端 未结 2 1936
再見小時候
再見小時候 2020-12-21 15:59

How can I extend the AutoComplete feature of a WinForm ComboBox to, for example, find matches of items using a regular expression or for simplicity to find items that contai

相关标签:
2条回答
  • 2020-12-21 16:23

    The AutoCompleteMode in Windows Forms does not (as of now) support filtering with regular expression or matching from the middle. It supports prefix filtering only.

    The API to reset the autocomplete options as you type is IAutoCompleteDropDown::ResetEnumerator. You need to call it in the TextChanged event. On Windows Vista or later you can call IAutoComplete2::SetOptions with ACO_NOPREFIXFILTERING to disable prefix filtering.

    0 讨论(0)
  • 2020-12-21 16:35

    For finding the existing list item that best matches what the user has typed, you can set the AutoCompleteMode property on the ComboBox to AutoCompleteMode.Append and the AutoCompleteSource to AutoCompleteSource.ListItems.

    If you want to use more complex logic to perform the auto-complete, look at doing something with the TextChanged event. An Example

    0 讨论(0)
提交回复
热议问题