vb.net 中按钮的热键 [英] Hotkey to button in vb.net

查看:25
本文介绍了vb.net 中按钮的热键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何向该按钮添加热键?现在的按钮,如果你用鼠标点击它,它会激活麦克风,这样你就可以说话,其他人可以听到你的声音,如果你第二次点击它,它会关闭麦克风,这样没人能听到你的声音.

How do i add a hotkey to this button? The button right now, if you click on it with your mouse it will activate the microphone so you can talk and other people can hear you, if you click it a second time it will de-activate the microphone so nobody can hear you.

我需要制作Ctrl"键,激活它并停用它

I need to make the "Ctrl" Key, activate it and deactivate it

    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

推荐答案

确实,您不应该为此使用 Ctrl.您可以在 ToolStripButton1.Name 中将 & 放在您希望成为快捷方式的字母之前.但是,如果您必须这样做,这应该可行:

Truly you shouldn't use Ctrl for that. You can put & before letter that you would like to be shortcut in ToolStripButton1.Name. But if you must this should work:

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 语句的正确格式:

Correct format with switch statement:

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

这篇关于vb.net 中按钮的热键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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