winform中窗体的快捷鍵设置

1、将Form的KeyPreview属性设置True

2、对KeyDown事件写入代码
 private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F2)
            {
                MessageBox.Show("你按下了F2键");
                //解发button1的单击事件
                button1_Click(bt_save, null);
            }

        }

posted @ 2009-02-07 17:01  kaka9  阅读(1273)  评论(0编辑  收藏  举报