Article ID: 948869
This article has been archived. It is offered "as is" and will no longer be updated.
RAPID PUBLISHING ARTICLES PROVIDE INFORMATION DIRECTLY FROM WITHIN THE MICROSOFT SUPPORT ORGANIZATION. THE INFORMATION CONTAINED HEREIN IS CREATED IN RESPONSE TO EMERGING OR UNIQUE TOPICS, OR IS INTENDED SUPPLEMENT OTHER KNOWLEDGE BASE INFORMATION.
If a Windows Forms form contains a DropDownList ComboBox control and the user drops down the list and tabs away from the control.
The item the user had hovered over will be saved but the SelectedIndexChanged event does not fire.
This is a bug in the underlying comctl32.dll (v6), which handles the themed ComboBoxes. Tabbing off of an item in the DropDownList the ComboBox is supposed to cancel the selection, and it correctly fires a CBN_SELENDCANCEL notfication and not the CBN_SELENDOK notification which WinForms wraps in the SelectedIndexChanged event. The problem is that instead of reverting to the prior selection it "reverts" back to the same new selection.
This can be worked around by forcing the ComboBox closed when tabbing off, which forces the selection to be changed fully before it can be "cancelled".
public class MyComboBox : ComboBox
protected override bool ProcessDialogKey(Keys keyData)
if (keyData == Keys.Tab)
this.DroppedDown = false;
return base.ProcessDialogKey (keyData);
MICROSOFT AND/OR ITS SUPPLIERS MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY, RELIABILITY OR ACCURACY OF THE INFORMATION CONTAINED IN THE DOCUMENTS AND RELATED GRAPHICS PUBLISHED ON THIS WEBSITE (THE “MATERIALS”) FOR ANY PURPOSE. THE MATERIALS MAY INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS AND MAY BE REVISED AT ANY TIME WITHOUT NOTICE.
TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, MICROSOFT AND/OR ITS SUPPLIERS DISCLAIM AND EXCLUDE ALL REPRESENTATIONS, WARRANTIES, AND CONDITIONS WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO REPRESENTATIONS, WARRANTIES, OR CONDITIONS OF TITLE, NON INFRINGEMENT, SATISFACTORY CONDITION OR QUALITY, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THE MATERIALS.