[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 404
  • Last Modified:

ComboBox Select Method

I have a DGV with two combobox columns. Once the DGV is loaded, my first selection in the first combobox is selected by the drop-down. After that, when subsequent comboboxes have focus, I can press the space bar and the selection from the previous combobox is shown. However, if I TAB off of this combobox, the combobox goes blank. I suspect that pressing the spacebar will cause the combobox to show the previous selection, but it does not actually SELECT what is shown in the combobox.

How can I have the combobox actually select what is shown when the spacebar is pressed so it will not go blank when the focus is lost (by TAB or RIGHT/LEFT ARROW) to the next column?

  • 2
1 Solution
Pressing the Enter key after selecting the value with Space should save the value.
Tim313Author Commented:

I would have thought so too, but pressing the Enter key causes the combobox to go blank. Seems the item is being visually shown in the cb on the spacebar press, but the value has not been selected by the spacebar press...

If the cb has focus and I press the spacebar, the previous selected item shows in the cb, I can then up arrow (does not open the drop-list but shows the previous item in the list, highlighted), then down arrow (does not open the drop-list but goes back to my desired item, also highlighted) and tab off the cb to the next column and the cb value is saved.

Any property setting I may have wrong, or do I need to have an event procedure to handle the spacerbar press to select the item prior to the cb losing focus?

Any help is appreciated,

I think you would need to use a keypress event to make cb realize the selection has changed.

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now