如何防止文本编辑框在按下 Enter 键时发出蜂鸣声?
我正在开发的 Windows 窗体 C# 应用程序中有一个文本编辑字段,在该功能发生后,窗口会发出叮当声。我找到了一些解决方案,但它仅适用于 C++,我不知道如何将其转换为零,因为它是 char 和非法转换,即使我手动将其转换为 char,它仍然会发出蜂鸣声。
非常感谢任何帮助!
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);
}
}
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);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须防止击键到达本机控件。设置 e.Handled = true
You have to prevent the keystroke from reaching the native control. Set e.Handled = true