How to stop “Ding” sound when pressing “Enter” in TextBox

04 Aug

Very simple way to remove the annoying beep sound from pressing enter in a single-line text box, for example in a console, or login form. Very simple, no multiline, and the sounds gone!

private void txtValue_KeyUp(object sender, KeyEventArgs e)
    if (e.KeyCode == Keys.Enter)
        e.SuppressKeyPress = true;
private void txtValue_KeyPress(object sender, KeyPressEventArgs e)
    if (e.KeyChar == (char)Keys.Enter)
        e.Handled = true;
Leave a comment

Posted by on August 4, 2012 in Visual C# . NET


Tags: , , , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: