操作功能键preSS [英] handling function key press

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

问题描述

我有5个按钮一个C#的形式。用户输入信息,并根据上的功能键的preSS,则执行特定动作。 <大骨节病> F9 -execute命令,<大骨节病> F6 - 保存,<大骨节病> F3 -lookup。

I have a C# form with 5 buttons. The users enters the information and depending on the press of a function key, a specific action is performed. F9-Execute Order, F6-Save, F3-LookUp.

我已经加入了foolowing code:

I have added the foolowing code:

OnForm_Load

OnForm_Load

this.KeyUp += new System.Windows.Forms.KeyEventHandler(KeyEvent);

private void KeyEvent(object sender, KeyEventArgs e) //Keyup Event 
    {
        if (e.KeyCode == Keys.F9)
        {
            MessageBox.Show("Function F9"); 
        }
        if (e.KeyCode == Keys.F6)
        {
            MessageBox.Show("Function F6");
        }
        else
            MessageBox.Show("No Function");

    }

但没有任何反应。

but nothing happens

感谢

推荐答案

您需要设置

KeyPreview=True

有关表单。否则键preSS是由具有焦点的控制吞噬。

for your form. Otherwise key press is swallowed by the control that has focus.

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

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