Avoid Windows 'Ding' when Enter is pressed in TextBox with OnKeyUp

ibram picture ibram · Jul 12, 2011 · Viewed 9.2k times · Source

If a user hits enter in a windows forms textbox with a KeyUp Event, windows sounds a beep or ding. I could not determine why this happens and how I could avoid this.

Any help would be appreciated.

Answer

Camilo Martin picture Camilo Martin · Feb 10, 2013

Actual solution for getting rid of the sound:

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