How to remove Windows BIP sound in c#?

Asked

Viewed 527 times

0

I hope you guys are okay. I developed a C# application in Visual Studio, but when pressing the 'TAB' key to change textBox1 to textBox2, it makes the sound of Windows (which is actually the ENTER key I changed in the script). How do you get that sound out? I tried the code below but it didn’t work...

private void textBox1_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.KeyCode == Keys.Tab)
        {
            e.SuppressKeyPress = true;
        }
    }

Thank you!

1 answer

1

You have to prevent the event KeyPressed is generated, which is such a beep. For this, you have to indicate that the event was successfully completed:

private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.Tab)
    {
        textBox2.Select();
        textBox2.Focus();
        e.Handled = e.SuppressKeyPress = true;
    }
}
  • 1

    Thanks, but it didn’t work. Alias your tip worked, but I found the problem...was a block I had put to trigger the Tab key instead of Enter. I had to comment this whole block to get the annoying beep.... Thanks!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.