2013-10-07 98 views
-9

我正在申請學校,我想在啓動屏幕上使用「按任意鍵繼續」功能。C#表單按任意鍵繼續

所以當有人按下一個鍵時,它會打開下一個表格。 任何人都可以幫助我嗎?提前致謝!

到目前爲止的代碼:

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

http://msdn.microsoft .com/en-us/library/system.windows.forms.form_events.aspx – michele

+0

您的問題與代碼無關 –

+0

使用'Form.KeyPress':http://msdn.microsoft.com/en-us/library /ms171538.aspx – Bolu

回答

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(); 
}