ComboBox Select Method

Posted on 2011-05-02
Last Modified: 2012-05-11
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?

Question by:Tim313
    LVL 83

    Expert Comment

    Pressing the Enter key after selecting the value with Space should save the value.

    Author Comment


    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,

    LVL 83

    Accepted Solution

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

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
    It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now