我做了一个方法来检测按键何时按下,但它不工作!我的继承人代码试图检测按键
void KeyDetect(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.W && firstload == true)
{
MessageBox.Show("Good, now move to that box over to your left");
firstload = false;
}
}
我也试图使keyeventhandler但是,它最高审计机关“不能分配到键检测,因为它是一个方法组”
public Gwindow()
{
this.KeyDetect += new KeyEventHandler(KeyDetect);
InitializeComponent();
}
谢谢!真的有帮助 –
...你确定应该是一个'='?另外,我不认为你需要额外的括号。 –