如何在V.B.Net中捕获功能键F1..F12 [英] How to Capture Function Keys F1..F12 in V.B.Net

查看:68
本文介绍了如何在V.B.Net中捕获功能键F1..F12的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我想在用户按下键时显示键值作为消息.
这里的功能键不起作用.
请帮助我.

Hi i want to show a key value as a message when user press a key.
here function key is not working.
please help me.

Private Sub show_key_val(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) _
         Handles txt_cust_name.KeyPress, txt_dist.KeyPress
       
MessageBox.Show(Convert.ToInt16(e.KeyChar))
       
    End Sub

推荐答案

该事件对您无济于事.使用另一个事件System.Windows.Forms.Control.KeyDown.它可以与不同的事件参数参数类型System.Windows.Forms.KeyEventArgs一起使用,这是您真正可以与功能键一起使用的类型.

使用类似if eventArgs.KeyCode = Keys.F1 …
的比较
参见:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.keydown.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system. windows.forms.keyeventargs.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system.windows.forms.keyeventargs.keycode.aspx [ ^ ](请在此处查看代码示例).

—SA
This event won''t help you much. Use another event System.Windows.Forms.Control.KeyDown. It works with different event arguments parameter type, System.Windows.Forms.KeyEventArgs, the one you really can use with functional keys.

Use comparisons like if eventArgs.KeyCode = Keys.F1 …

See:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.keydown.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.keyeventargs.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.keyeventargs.keycode.aspx[^] (please see a code sample here).

—SA


这篇关于如何在V.B.Net中捕获功能键F1..F12的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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