霓为衣兮风为裳 2015-06-10 15:26 采纳率: 30%
浏览 2062
已采纳

窗体无法接受键盘消息

用窗体生成器自动生成的代码

  private void Form1_KeyDown(object sender, KeyEventArgs e) {
            MessageBox.Show("af");
            if (listBox1.Items.Contains(e.KeyCode)) {
                listBox1.Items.Remove(e.KeyCode);
                listBox1.Refresh();


                //this part will increse the difficult of the game by putting down the interval
                if (timer1.Interval > 400) timer1.Interval -= 10;
                if (timer1.Interval > 250) timer1.Interval -= 8;
                if (timer1.Interval > 100) timer1.Interval -= 2;


                status.Update(true);
            } else {
                status.Update(false);
            }
            progressBar1.Value = 800 - timer1.Interval;
            labelCorrect.Text = "correct:  "+status.correct.ToString();
            LabelMiss.Text = "missed:  "+100;
            labelTotal.Text = "total;  "+status.total.ToString();
            labelAccuracy.Text = "Accuracy: "+status.total.ToString();

        }

按键之后程序无响应 对话框也弹不出来 求大神讲解

  • 写回答

4条回答 默认 最新

  • threenewbee 2015-06-10 15:29
    关注

    Form的keypreview设置为true
    看下Form1_KeyDown有没有绑定到KeyDown事件上

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?