开发者

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

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);

            }

 }


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜