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

窗体无法接受键盘消息

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

  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条)

报告相同问题?

悬赏问题

  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加
  • ¥15 用ns3仿真出5G核心网网元
  • ¥15 matlab答疑 关于海上风电的爬坡事件检测
  • ¥88 python部署量化回测异常问题