[英]PressKey on Form does work because of buttons Visual Studio 2013
我有以下问题。 我在 Visual Studio 2013 上有一个学校项目,我想通过按键盘上的任意键打开菜单表单。 到目前为止,我有以下代码。
public partial class START : Form
{
public START()
{
InitializeComponent();
this.KeyPress += new KeyPressEventHandler(START_KeyPress);
}
void START_KeyPress(object sender, KeyPressEventArgs e)
{
Meniu form2 = new Meniu();
form2.Show();
this.Hide();
}
问题是当我在表单上也有一些按钮时这不起作用。我认为它必须与表单焦点有关,但我不确定。 如果有人可以帮助我,我将非常感激。
该代码有效。 您只需激活 KeyPreview 属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.