在Windows捕获组合键事件窗体应用程序 [英] Capture combination key event in a Windows Forms application
本文介绍了在Windows捕获组合键事件窗体应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当用户按下<大骨节病>移骨节病> + <大骨节病> UP 骨节病>键,我希望我的形式通过调用一个消息框响应。
When the user presses the Shift + UP keys, I want my form to respond by calling up a message box.
我如何做到这一点在Windows窗体?
How do I do this in Windows Forms?
推荐答案
处理的的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.
这篇关于在Windows捕获组合键事件窗体应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文