英文:
How to mute enter-perssed sound in TextBox?
问题
I have this simple code:
private void Term_TextBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Enter)
Definition_TextBox.Focus();
}
that focuses the next TextBox in my form after Enter was pressed. Unfortunately, there is this Windows-like "bung" or "bing" sound while pressing Enter in a TextBox. How to disable it?
I tried to google it but couldn't find any suitable answer. I don't want to mute the whole application, only this element, this exact TextBox. Do you know how to do it? Is there any 'elegant' solution to this problem? I'm using .NET Framework 4.7.2 with C#.
Thanks in advance.
英文:
I have this simple code:
private void Term_TextBox_KeyDown(object sender, KeyEventArgs e)
if (e.KeyData == Keys.Enter)
Definition_TextBox.Focus();
that focuses next TextBox in my form after enter was pressed. Unfortunetly there is this windows-like "bung"/"bing" sound while pressing entere in a TextBox. How to disable it?
I tried to google it but couldn't find any suitable answer. I don't want to mute whole application, only this element, this exact TextBox. Do you know how to do it? Is there any 'elegent' solution to this problem? I'm using .NET Framework 4.7.2 with c#.
Thanks in advance.
答案1
得分: 0
private void Term_TextBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Enter)
{
e.SuppressKeyPress = True;
Definition_TextBox.Focus();
}
}
这是一个处理在 Windows Forms 中按下键盘按键事件的代码示例。当按下的按键是 Enter 键时,它会阻止默认的按键处理,并将焦点转移到 Definition_TextBox 控件上。
英文:
private void Term_TextBox_KeyDown(object sender, KeyEventArgs e)
if (e.KeyData == Keys.Enter)
e.SuppressKeyPress = True
Definition_TextBox.Focus();
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论