1 /// <summary> 2 /// 重写键盘处理事件,处理退出和回车按钮 3 /// </summary> 4 protected override bool ProcessCmdKey(ref Message msg, Keys keyData) 5 { 6 switch (keyData) 7 { 8 // 保存并退出 9 case Keys.Escape://ESC 10 BtnOK_Click(null, null); 11 break; 12 13 case Keys.Enter: 14 BtnCancel_Click(null, null); 15 break; 16 } 17 return base.ProcessCmdKey(ref msg, keyData); 18 }