如何在选择项目时保持comboBox打开 [英] How to keep comboBox open while selecting items
问题描述
我有一个Windows Form自定义组合框,我在dataGridView中托管。在用户选择项目时,我无法弄清楚如何打开下拉列表。没有关闭事件。有谁知道这是如何实现的?我很感激任何建议。
提前致谢,
-DA
I have a Windows Form custom comboBox that I'm hosting in a dataGridView. I can't figure out how to keep the drop down list open while the user selects items. There is no closing event to hook off of. Does anyone know how this is accomplished? I would appreciate any advice.
Thanks in advance,
-DA
推荐答案
假设您的自定义ComboBox继承自WinForms本机ComboBox:
将此放入SelectedIndexChanged EventHandler:
Assuming your custom ComboBox inherits from the WinForms native ComboBox:
Putting this in the SelectedIndexChanged EventHandler:
if(! comboBox1.DroppedDown) comboBox1.DroppedDown = true;
在您单击ComboBox的选择文本显示区域之前,或者在ComboBox外部单击以使ComboBox失去焦点时,将强制DropDown保持不变。
您正在做一些实现多选的事情吗?
Will force the DropDown to stay dropped until you either click in the selection text display area of the ComboBox, or you click outside the ComboBox so that the ComboBox loses Focus.
Are you doing something that implements multi-selection ?
这篇关于如何在选择项目时保持comboBox打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!