I am implementing a custom message box as a modal windows form. When I call my static Show method from within the ValueChanged event of an UltraCombo (Infragistics v7.1), the message box is displayed and the Enter/Esc keys do trigger the Accept/Cancel button Click events.
However, the dropdown of the combo is still visible on the owner form and the first time I click a button on the message box the Click event does NOT fire, but, the dropdown closes up. A subsequent click does trigger the event.
If I select a value in the combo using the arrow keys, so that the dropdown is not shown, this problem does not occur. Also, I tried setting the focus and the Capture property in the OnActivate and OnShown methods and this does highlight the button, but, the first mouse click still seems to be linked to the combo.
Any suggestions on how I can fix this would be appreciated.
Have you tried closing the dropdown before calling the MessageBox? I think there's a CloseUp method or a settable IsDroppedDown or DroppedDown property.
Thanks Mike.
That does the trick, but, I was hoping there was something I could change in either my message box class or my derived combo class that would globally capture or release the mouse, respectively, without globally changing the dropdown functionality.
Is this problem more related to the modal form, the combo, or both?
Well, this is only a guess... but what's probably happening is that the ValueChanged event of the Combo is getting triggered by the KeyDown message. Showing a modal dialog in this event means that the corresponding KeyUp is getting lost becuse the modal dialog gets the message rather than the Combo.
Another possible option would be not to show the dialog directly from the ValueChanged event. Perhaps you could use the KeyUp event. Or maybe use a BeginInvoke to call a method that shows the modal dialog indirectly.