0
我想將窗體中的按鈕與鍵盤上的字母「S」鏈接起來。 例如: 如果我按「Button1的」鑰匙「S」會自動按下如何在C#窗體中將按鈕與鍵盤鏈接起來
我想將窗體中的按鈕與鍵盤上的字母「S」鏈接起來。 例如: 如果我按「Button1的」鑰匙「S」會自動按下如何在C#窗體中將按鈕與鍵盤鏈接起來
更多關於這在MSDN article for the SendKeys
class:
// Clicking Button1
private void Button1_Click(System.Object sender, System.EventArgs e)
{
SendKeys.Send("S");
}
什麼將是完成?你想把「S」放在文本框或什麼的? – 2015-02-10 14:19:45
請注意,如果您單擊一個按鈕,則該按鈕將具有焦點,因此按鍵將(通常)指向該按鈕。但是,您可以執行SendKeys.Send(「S」);'來響應按鈕按下。 – 2015-02-10 14:21:29
沒有老兄,我只是想在Windows窗體中按「Button1」,而在鍵盤上自動按下字母「S」。 – 2015-02-10 14:23:57