vb.net怎么设置快捷键
1个回答
展开全部
新建一个Form1把Form1的KeyPreview改成True
拖入一个Button1到Form1上面
然后加入以下代码
Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
If e.KeyData = (Keys.Alt Or Keys.G) Then
Button1.PerformClick() '或者用Button1_Click(Nothing, New EventArgs)
'快捷键Alt+G触发Button1_Click()事件。
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Button1.Size = New Size(180, 23)
Button1.Text = "我被局部快捷键给召唤了~"
End Sub
拖入一个Button1到Form1上面
然后加入以下代码
Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
If e.KeyData = (Keys.Alt Or Keys.G) Then
Button1.PerformClick() '或者用Button1_Click(Nothing, New EventArgs)
'快捷键Alt+G触发Button1_Click()事件。
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Button1.Size = New Size(180, 23)
Button1.Text = "我被局部快捷键给召唤了~"
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询