locked
Can I select item in ToolStripComboBox with mouse up? RRS feed

  • Question

  • Hi all

    I'm using VS 2005. I have this behaviour problem with ToolStripComboBox and ComboBox.

    1. Run an application containing a ComboBox
    2. Mouse down on the ComboBox (don't mouse up)
    3. Drag down over items in the dropdown and mouse up on one
     
     Actual Results: As you drag over the items in the dropdown, the item which you hover over doesn't highlight, and when I mouse up doesn't select the item too.   
      
     Expected Results: Able to select item in combobox with mouse up and also highlight the item when I hover over when in mouse down.
    At the same time, I'm still want to keep the default behaviour as in click on the combobox and release mouse button. Then select the item with mouse down.

    Basically the behaviour I want can be seen in ToolStripDropDownButton and also in the combobox used in the standard toolbar - Solution Configurations Solution and Platforms in Visual Studio 2005.

    Please advise how can this be done. If this can be done, I would like to know if this can be done on ContextMenuStrip as well. Thanks alot.
    Wednesday, August 26, 2009 8:54 AM

Answers

  • Right.  It only shows how to capture the dropdown window and get Windows messages for it.  I was hoping it would be enough to convince you that this is a problem you should not fix.  If you really do want to fix it, that code is crucial to get started.

    Hans Passant.
    • Marked as answer by hengster Thursday, August 27, 2009 2:11 PM
    Thursday, August 27, 2009 10:18 AM

All replies

  • Try MouseHover or MouseEnter event on it.
    Wednesday, August 26, 2009 9:32 AM
  • Hi falaque

    I'm pretty new in programming. I've sort of figure up to use these event to change the behaviour, but how can I achieve that? Can you provide some sample code for this? Thanks alot.

    I'm still curious what is the control that is used in the combobox used in the standard toolbar - Solution Configurations Solution and Platforms in Visual Studio 2005. If there is an existing control which I can use, I will not need to implement more coding to make it work.

    Regards
    hengster
    Wednesday, August 26, 2009 9:42 AM
  • You can't really fix this, it is behavior controlled by code inside Windows.  The dropdown list of a ComboBox is a native Windows control that gets created on-the-fly when you user clicks the dropdown button.  You can't subscribe to any of its events.

    A ToolStripDropDownButton is different, it is not a native Windows control but completely implemented in .NET code.  A strong argument could be made that it is actually TSDDB that has buggy behavior since it doesn't behave like the native Windows controls.  Many of the ToolStripItem controls have non-standard behavior like this.

    It is technically possible to dynamically wire a wrapper for the dropdown list, getting Windows messages for it.  This requires heavy P/Invoke and 4 readings of Petzold's Programming Windows.  This thread shows the approach.

    Hans Passant.
    Wednesday, August 26, 2009 1:08 PM
  • Hi Hans

    Just to confirm : The thread you gave me just create a tooltip for the combobox item. It does not solve the problem I encountered right?

    Thanks.
    Thursday, August 27, 2009 6:26 AM
  • Right.  It only shows how to capture the dropdown window and get Windows messages for it.  I was hoping it would be enough to convince you that this is a problem you should not fix.  If you really do want to fix it, that code is crucial to get started.

    Hans Passant.
    • Marked as answer by hengster Thursday, August 27, 2009 2:11 PM
    Thursday, August 27, 2009 10:18 AM
  • Thanks, Hans. I'm convinced. You save me lots of time to find the solution.
    Thursday, August 27, 2009 2:11 PM