如何制作快捷键 [英] How to make shortcut key

查看:91
本文介绍了如何制作快捷键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在C#GUI Form中制作Shortcut Key.请举个例子.
谢谢...

How to make Shortcut Key in C# GUI Form. Please give me some example.
Thank you...

推荐答案

如果您确实要创建自己的快捷方式,那么您可以在按下任意键时捕获事件,并且可以使用关于按键.

If you really want to create your own shortcuts then u can catch the event when any of the key pressed and you can add corresponding functions with respect to the key pressed.

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData == Keys.F1)
            {
                //Help function or your own function
            }
            //return base.ProcessCmdKey(ref msg, keyData);

        }



希望对您有帮助.



Hope it helps you.


首先需要将表单的KeyPreview属性设置为true.
然后在表单的keyDown事件中,您可以这样写:
first of all you need to set the KeyPreview property of your form to true .
then in the keyDown event of your form , you can write sth like this :
if ( e.Alt && e.KeyCode == Keys.H )
{
   MessagbeBox("Alt-H was pressed");
}


您还可以使用e.Modifiers来检查alt-shift或ctrl的组合键.


you can also use e.Modifiers to check for key combinations with alt-shift or ctrl


您可以看到此链接->


快捷键
You can see this link ->


shortcut key


这篇关于如何制作快捷键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆