Winform窗体对键盘的响应处理

Winform

组合键响应处理:
//Support Shortcut Key
        private void MainForm_KeyUp(object sender, KeyEventArgs e)
        {
            if ((e.Modifiers & Keys.Control) != 0 && e.KeyCode == Keys.G)
                {
                    FrmGoto frmGoto = new FrmGoto();
                    frmGoto.StartPosition = FormStartPosition.CenterScreen;
                    frmGoto.Show();
                }
        }
        
设置Form 窗体中默认的回车及ESC处理:
在窗体的Designer.cs或者Form.Load事件中加入
this.AcceptButton = this.btnOK; 响应Enter
this.CancelButton = this.btnCancel; 响应ESC

posted on 2013-02-18 10:23  fery  阅读(328)  评论(0编辑  收藏  举报