vb.net实现按字母控制button
1个回答
展开全部
如果是用键盘来代替鼠标点击按钮,用下面的代码
Public Class Form1
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
Select Case Chr(e.KeyValue)
Case "A"
Button1_Click(sender, e)
Case ""
End Select
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.KeyPreview = True '窗体下注册键盘事件
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox("键盘A键按下")
End Sub
End Class
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询