如何为此按钮添加热键? 现在按钮,如果你用鼠标点击它,它将激活麦克风,这样你就可以说话,其他人可以听到你,如果你再次点击它,它将取消激活麦克风,所以没有人能听到你。< / p>
我需要制作&#34; Ctrl&#34;键,激活它并停用它
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.Control Then
sooket.Client.SendCommand(New Command(CommandType.jampee, sooket.Client.IP, UserName & "|" & NameMic & "|" & Roomname.Trim & "|" & "plassmic" & "|" & "microphoneee.png" & "|" & "|" & "okmic" & "|" & "Timeok" & "|"))
' mic()
Select ToolStripButton1.Text
Case "Off"
Case "On"
End Select
End If
End Sub
答案 0 :(得分:1)
你真的不应该使用Ctrl
。您可以在&
之前将ToolStripButton1.Name
放在您希望成为快捷方式的字母之前。但如果你必须这样做:
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.Control Then
'Your code here
End If
End Sub
使用switch语句更正格式:
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.Control Then
Select Case ToolStripButton1.Text
Case "Off"
ToolStripButton1.Text = "On"
Case "On"
ToolStripButton1.Text = "Off"
End Select
End If
End Sub