C# 窗体按任意键继续

本文关键字:继续 任意键 窗体 | 更新日期: 2023-09-27 18:34:08

我正在申请学校,我想在启动屏幕上使用"按任意键继续"功能。

因此,当有人按下一个键时,它会打开下一个表单。谁能帮我解决这个问题?提前感谢!

到目前为止的代码:

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

C# 窗体按任意键继续

您要查找的操作是窗体的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();
 }