How do I prevent the textedit box from beeping when enter is pressed?

1.8k views Asked by At

I have a text edit field in a Windows Form C# application I am developing and after the function occurs, windows dings. I found some solutions but it applied only to C++ and I couldn't figure how to translate it making the key event to zero since it is a char and illegal cast, even if i do manually cast it to char, it still beeps.

Any help is greatly appreciated!

private void txtPhrase_KeyPress(object sender, KeyPressEventArgs e)
{
            if (e.KeyChar == (char)13)
            {
                // keyPress seems to initiate the system beep.  Why?
                btnSpeak_Click(sender, e);

            }

 }
1

There are 1 answers

3
Hans Passant On BEST ANSWER

You have to prevent the keystroke from reaching the native control. Set e.Handled = true