Windows应用程序中的Combobox.DroppedDown问题 [英] Combobox.DroppedDown Problem in Windows app

查看:98
本文介绍了Windows应用程序中的Combobox.DroppedDown问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我已将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 set DroppedDown equal to true, it opens the drop down to the ComboBox. That means that that DropDown now has the focus. The next click away from the DropDown 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 the DropDown 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 the form_MouseMove event and store that position). Then, hook into the ComboBox_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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆