How can you create Alt shortcuts in a Windows Forms application?

前端 未结 3 2359
天涯浪人
天涯浪人 2021-02-20 09:48

I\'d like to create keyboard shortcuts for some controls in my Windows Forms application.

Example:

\"Screens

3条回答
  •  北海茫月
    2021-02-20 10:06

    this.KeyDown += new KeyEventHandler(Form1_KeyDown);
    
    void Form1_KeyDown(object sender, KeyEventArgs e) 
    { 
     if (e.Alt && e.KeyCode == Keys.W)
     { 
       btnShowConstructionCdFun(); 
     } 
    }
    

提交回复
热议问题