TextBox:按Ctrl + a时如何禁用蜂鸣声?

时间:2015-05-16 18:07:01

标签: .net vb.net winforms visual-studio

我有一个标准的文本框。我添加了以下代码以使用户能够按 Ctrl + a 来选择RTB中的所有文本:

Private Sub tb_teamList_KeyDown(sender As Object, e As KeyEventArgs) Handles tb_teamList.KeyDown
    If e.Control = True AndAlso e.KeyCode = Keys.A Then
        tb_teamList.SelectAll()
    End If
End Sub

现在,当用户按 Ctrl + a 时,它仍然会发出蜂鸣声。有没有办法让按键按下时发出哔哔声?

1 个答案:

答案 0 :(得分:0)

好的是在多行TextBox中按Ctl + A时禁用哔声,您需要在代码中添加e.SuppressKeyPress = True

Private Sub tb_teamList_KeyDown(sender As Object, e As KeyEventArgs) Handles tb_teamList.KeyDown
    If e.Control = True AndAlso e.KeyCode = Keys.A Then
        tb_teamList.SelectAll()
        e.SuppressKeyPress = True
    End If
End Sub