How to remove sound from Windows BIP in C #?

0

I hope you are well. I've developed a C # application in Visual Studio, but by pressing the 'TAB' key to switch from textBox1 to textBox2, it makes the Windows sound (which is actually the ENTER key that I changed in the script). How do you get the sound out? I tried the code below but it did not work ...

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

Thank you!

    
asked by anonymous 02.08.2017 / 01:46

1 answer

0

You have to prevent the KeyPressed event from being generated, which is the beep. To do this, you have to indicate that the event has been successfully completed:

private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.Tab)
    {
        textBox2.Select();
        textBox2.Focus();
        e.Handled = e.SuppressKeyPress = true;
    }
}
    
02.08.2017 / 05:12