组合框不会失去焦点 [英] ComboBox not losing focus

查看:235
本文介绍了组合框不会失去焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在有问题的ComboBox控件。我在GUI中没有专家,但我知道这个问题涉及到控制的重点。

I've been having problems with the ComboBox control. I'm no expert in GUI, but I know this problem is related to the control's focus.

由于某种原因,组合框不会失去它的焦点,当我点击它的外面。例如说:

For some reason, the ComboBox does not lose its focus when I click outside of it. Say for example:

  1. 在我点击组合框列出的项目。
  2. 在我选择一个项目。这将关闭组合框。
  3. 在我点击第二个组合框,第一个保持关注。

  1. 单击一个组合框(包括点,实体和线框)。
  2. 单击窗体上。 preSS无论是P,S或W见的选择得到改变。

请注意,该组合框只具有的 DropDownStyle 的设置为 ComboBoxStyle.DropDownList 的。这意味着它的默认组合框的行为。我认为,默认行为是,当你点击了它,或者在其他控件(按钮或ComboBox)组合框会失去重点。这不是这里的情况,为什么?

Note that the ComboBox only has the DropDownStyle set to ComboBoxStyle.DropDownList. This means that it's the default ComboBox behavior. I thought that the default behavior was that the ComboBox would lose its focus when you clicked out of it, or on another control (button or ComboBox). It is not the case here, why?

更新: 我需要的是某种ActiveComponent =空的。这样的行为应该是类似于Visual Studio的一个人,你选择标准工具栏在调试或发行(组合框)。目前,如果我点击了组合框之外,它仍然集中。

UPDATE: What I need is some sort of ActiveComponent = null. The behavior should be similar to the one of Visual Studio were you select Debug or Release (ComboBox) in the standard toolbar. Currently, if I click outside of the ComboBox, it is still focused.

推荐答案

您可能想看看本主题。尝试设置的CausesValidation为false,组合框,看你能不能离开它。如果抛出一个异常,在OnValidating事件处理程序,也不会取消选择框。

You may want to take a look at This topic. Try setting CausesValidation to false on the combo box, see if you can leave it. If an exception is thrown in the OnValidating event handler, it won't deselect the box.

这篇关于组合框不会失去焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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