//方法一.在form_load的时候写上 // this.KeyPreview=true; //表示窗体接受按键事件 //然后在KeyDown事件中写入如下代码实现输入的是否是Ctrl+A的组合键: private void Form1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.A && e.Modifiers == Keys.Control) MessageBox.Show("Ctrl+R"); } //方法二.验证输入的是不是组合键盘Ctrl+A protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (keyData == (Keys.Control | Keys.A)) { MessageBox.Show("Ctr+A"); } return base.ProcessCmdKey(ref msg, keyData); } //方法三.或者使用一般按键处理也就可以了 protected override bool ProcessDialogKey(Keys keyData) { if (keyData == (Keys.Control | Keys.A)) { MessageBox.Show("Ctr+A"); } return base.ProcessDialogKey(keyData);
转 : https://www.cnblogs.com/eecc/articles/1260420.html
标签:Control,MessageBox,组合,Ctrl,C#,keyData,Show,快捷键,Keys From: https://www.cnblogs.com/fps2tao/p/17012074.html