Microsoft KB Archive/905720

= You cannot control the behavior that occurs when a user presses ENTER when you add a ToolStripComboBox control to a Windows Application project that uses the .NET Framework 2.0 =

Article ID: 905720

Article Last Modified on 12/3/2007

-

APPLIES TO


 * Microsoft .NET Framework 2.0

-





SYMPTOMS
When you add a ToolStripComboBox control to a Microsoft Windows Application project that uses the Microsoft .NET Framework 2.0, you cannot control the behavior that occurs when a user presses ENTER.



CAUSE
This problem occurs because the ToolStripComboBox and ComboBox controls do not contain an AcceptsReturn property that you can use to control ENTER key behavior.



WORKAROUND
To work around this problem, use one of the following methods:   Add a KeyUp event handler to the ToolStripComboBox control. To do this, use code that resembles the following code example. private void toolStripComboBox1_KeyUp(object sender, KeyEventArgs e) { if (e.KeyData == Keys.Enter) {       MessageBox.Show(&quot;ENTER&quot;); }; }   Create a custom ToolStripComboBox control that encapsulates a custom ComboBox control. In this custom ComboBox control, override the IsInputKey method to capture the ENTER key. To do this, use code that resembles the following code example. protected override bool IsInputKey(System.Windows.Forms.Keys keyData) {   if(keyData == Keys.Enter){ return true; }else{ return false; } } 



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.



MORE INFORMATION
For more information about the ToolStripComboBox class, visit the following Microsoft Developer Network (MSDN) Web site:

http://msdn2.microsoft.com/en-us/library/system.windows.forms.toolstripcombobox.aspx

Keywords: kbinfo kbtshoot kbbug kbprogramming kbprb KB905720

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.