简体   繁体   English

关闭表单时在C#中禁用丁丁声

[英]Disable Ding sound in c# on form closing

I have an annoying issue. 我有一个烦人的问题。 While a fellow stacker provided a working solution to a similar issue, i still can't get it to work in a particular instance. 尽管有一个堆垛机为类似的问题提供了可行的解决方案,但我仍然无法使其在特定实例中正常工作。

i have a search form. 我有一个搜索表。

i open it with CTRL + F. In order to prevent the annoying DING sound i put 我用CTRL + F打开它。为了防止发出讨厌的丁音

e.Handled = true;
e.SuppressKeyPress = true;

in the relevant handler. 在相关的处理程序中。 Works like a charm. 奇迹般有效。 On the second form, on the other hand 另一方面,第二种形式

    private void textBox1_KeyUp(object sender, KeyEventArgs e)
    {
        if (e.KeyCode != Keys.Escape) return;
        e.Handled = true;
        e.SuppressKeyPress = true;
        Close();
    }

Still makes the Ding before closing. 仍使丁在关门前。 Any help would be greatly appreciated! 任何帮助将不胜感激!

After i finished this question, i changed the handler. 完成此问题后,我更改了处理程序。

The same code, but on key down . 相同的代码,但按下键

No more dinging! 不再叮叮当当!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM