在VB.NET中按功能键(F9) [英] Function Key (F9) press in VB.NET

查看:95
本文介绍了在VB.NET中按功能键(F9)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好所有访客
我的功能键有问题.
我想使用事件Form_key_press.
在我这样使用的代码中:

Hi all visitors
i have problem with function key.
i want to use event Form_key_press.
in the code i use like this:

Private Sub frmmain_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress

       'When press escape key will alert message box "Escape"
       If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Escape) Then
           MsgBox("Escape")
       End If

       'When press F9 key alert empty message
       If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.F9) Then
           MsgBox("F9")
       End If
   End Sub



有人知道我该如何考虑代码中的功能键吗?

最好的问候,
TONY



Does anybody know how i can consider the function key in code?

Best Regards,
TONY

推荐答案

使用KeyDown事件
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
  If e.KeyCode = Keys.F9 Then
    MsgBox("f9")
  End If
End Sub


<br />
<br />
Use KeyUp Event<br />
<pre lang="vb"><br />
Imports System.Windows.Forms.KeyPressEventArgs<br />
<br />
  Private Sub demo_keyup(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp<br />
    If e.KeyCode = Keys.F1 Then<br />
      MsgBox("f1:HELP")<br />
<br />
    End If<br />
  End Sub<br />
</pre><br />
<br />
 This is another format to using keyup functionality .<br />
   <br />


这篇关于在VB.NET中按功能键(F9)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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