且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Windows捕获组合键事件窗体应用程序

更新时间:2023-12-06 10:10:52

处理的的KeyDown 事件,碰到这样的:

Handle the KeyDown event and have something like:

if (e.Modifiers == Keys.Shift && e.KeyCode == Keys.Up)
{
    MessageBox.Show("My message");
}



事件处理程序是主窗体上,你需要设置的KeyPreview 属性真正。这可以从属性对话框的设计模式来完成。

The event handler has to be on the Main Form and you need to set the KeyPreview property to true. This can be done in design mode from the properties dialog.