WinForms ComboBox SelectedIndexChanged not firing when typing few chars followed by Alt+Down

前端 未结 5 2051
无人共我
无人共我 2021-02-19 03:21

In short

When I type a character in a ComboBox, press Alt+Down followed by Enter or Tab, the SelectedIndexChanged event doesn\'t fire, even though the S

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-19 04:06

    The appropriate DropDown property value here is DropDownList. It doesn't have this problem.

    Coming up with a workaround for your specific problem with the DropDown style set to DropDown is quite difficult. It allows the user type arbitrary text and even a perfect match with one of the dropdown items doesn't change the SelectedIndex. You'd have to implement the Validating event and look for a match yourself. The DropDownClosed event would be good for your specific scenario. But really, always use DropDownList if you want perfect matches.

提交回复
热议问题