Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 905720 - Last Review: December 3, 2007 - Revision: 1.2
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
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.
This problem occurs because the
ToolStripComboBox and
ComboBox controls do not contain an
AcceptsReturn property that you can use to control ENTER key behavior.
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("ENTER");
};
} - 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;
}
}
Microsoft
has confirmed that this is a problem in the Microsoft products that are listed
in the "Applies to" section.
For more information about the
ToolStripComboBox class,
visit the following Microsoft Developer Network (MSDN) Web site:
APPLIES TO
- Microsoft .NET Framework 2.0
| kbinfo kbtshoot kbbug kbprogramming kbprb KB905720 |
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate