Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ComboBox not losing focus

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. I click on the ComboBox to list its items.
  2. I select one item. This closes the ComboBox.
  3. I click on the second ComboBox, the first one stays focused.

OR

  1. Click on a ComboBox (contains Point, Solid and Wireframe).
  2. Click on the form. Press either P, S or W. See the selection get changed.

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?

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.

like image 680
tomzx Avatar asked Aug 02 '09 17:08

tomzx


3 Answers

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.

like image 140
Brandon Avatar answered Sep 27 '22 17:09

Brandon


Are you sure the problem isn't because neither your frame or your other combobox have a way to gain focus?

like image 34
novacara Avatar answered Sep 27 '22 18:09

novacara


All you have to do is:

  1. go to property window of Combobox
  2. and set Allow Drop="true"

The property is intended for some other purpose but it works for this scenario too.

like image 33
Rajesh Avatar answered Sep 27 '22 18:09

Rajesh