Windows应用程序中的Combobox.DroppedDown问题 [英] Combobox.DroppedDown Problem in Windows app
问题描述
嗨
我已将ComboBox DroppedDown属性设置为true.
当ComboBox下拉时,我实际上必须单击两次以退出表单,或者需要单击两次以执行任何操作.
例如,在我的表单中,我有两个控件,一个ComboBox和一个按钮,单击它们即可关闭表单.我将ComboBox DroppedDown设置为true.当ComboBox DroppedDown = true时,要单击关闭"按钮,我需要单击两次以启动按钮上的click事件.
帮助我解决此问题.我也必须单击两次才能在表单上的任意位置单击.
问候,
Pawan.
Hi
I have set the ComboBox DroppedDown property to true.
When the ComboBox is dropped down, I have to actually click twice to get out of the form or need to click twice to do anything.
For example, in my form, I have two controls, a ComboBox and a button which when clicked just closes the form. I set the ComboBox DroppedDown = true. When the ComboBox DroppedDown = true, to click on Close button, I need to click twice to initiate the click event on the button.
Help me on how to fix this. I am having to click twice to click anywhere on the Form as well.
Regards,
Pawan.
推荐答案
将DroppedDown
设置为true时,它将打开下拉列表到ComboBox
.这意味着DropDown
现在具有焦点.再次点击DropDown
只会使其关闭,而不会激活其他任何内容.
那就是它的行为方式.当用户单击向下箭头时,也会发生相同的情况.下次单击时,只会导致DropDown
关闭,没有其他影响.
我能看到的唯一方法是跟踪鼠标在表单上的位置(因此,钩住form_MouseMove
事件并存储该位置).然后,钩入ComboBox_DropDownClosed
事件,并在事件关闭时,使用
检查鼠标下的控件类型
When you setDroppedDown
equal to true, it opens the drop down to theComboBox
. That means that thatDropDown
now has the focus. The next click away from theDropDown
will only cause it to close, but won''t activate anything else.
That''s just the way it behaves. The same thing happens when a user clicks the down arrow. The next time they click, it will only cause theDropDown
to close, nothing else.
The only way that I can see around that would be to keep track of where the mouse is on the form (so, hook theform_MouseMove
event and store that position). Then, hook into theComboBox_DropDownClosed
event and when it''s closed, check what type of control is under the mouse using
this.GetChildAtPoint(MousePosition)
如果是按钮,则单击它(例如:button1.PerformClick();
).或者,如果还有其他问题,请致电whatever.SetFocus();
and if it''s a button, click it (example: button1.PerformClick();
). Or, if it''s something else, call whatever.SetFocus();
这篇关于Windows应用程序中的Combobox.DroppedDown问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!