C#表单按任意键继续

时间:2013-10-07 10:45:19

标签: c#

我正在申请学校,我想在启动画面上使用“按任意键继续”功能。

所以当有人按下某个键时,它会打开下一个表格。 谁能帮我这个?提前谢谢!

到目前为止

代码:

//SOME ACTION//
   {
     Form2 f2 = new Form2();
     f2.Show();
     this.Hide();
   }

1 个答案:

答案 0 :(得分:1)

您要查找的内容是表单的KeyPress事件,因此您可以处理初始屏幕表单的KeyPress

 //you need to register the event handle to your form first.. 
 //so the following line could be in your start screen form's constructor  
 this.KeyPress += new KeyPressEventHandler(Form1_KeyPress); 

 //then you can open your new form as you suggested 
 void Form1_KeyPress(object sender, KeyPressEventArgs e) 
 {
     Form2 f2 = new Form2();
     f2.Show();
     this.Hide();
 }