当组合框处于事件状态时,如何捕获 Windows 窗体组合框中的回车键?
我试过听 KeyDown 和 KeyPress,我创建了一个子类并覆盖了 ProcessDialogKey,但似乎没有任何效果。
有什么想法吗?
/P
最佳答案
将 KeyPress 事件连接到这样的方法:
protected void myCombo_OnKeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13)
{
MessageBox.Show("Enter pressed", "Attention");
}
}
我已经在 VS2008 的 WinForms 应用程序中对此进行了测试,它可以正常工作。
如果它不适合您,请发布您的代码。
关于c# - 如何捕获 Windows 窗体组合框中的回车键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1226726/