如何在vb.net中检测箭头键? [英] How to detect arrow keys in vb.net?

查看:131
本文介绍了如何在vb.net中检测箭头键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用if语句在vb.net中检测箭头键?

How to detect arrow keys in vb.net using if statement?

推荐答案

检查按键的键代码.用例语句是示例

check keycode for the keypressed.Use case statements here''s the sample

Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
    ' Sets Handled to true to prevent other controls from
    ' receiving the key if an arrow key was pressed
    Dim bHandled As Boolean = False
    Select Case e.KeyCode
        Case Keys.Right
            'do stuff
            e.Handled = True
        Case Keys.Left
            'do other stuff
            e.Handled = True
        Case Keys.Up
            'do more stuff
            e.Handled = True
        Case Keys.Down
            'do more stuff
            e.Handled = True
    End Select
End Sub


这篇关于如何在vb.net中检测箭头键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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