| | |
TextBox ENTER and ESC sound OnKeyPress
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
Hi i will describe my problem.
When focus is on TextBox and we press ENTER or ESC then we will hear that sound. I'm trying to disable that. Did any one got that problem before ? I was trying to create my own SilentTextBox which will inherit from TextBox and disable that sound by overriding OnKeyPress. OnKeyDown, OnKeyUp and OnPreviewKeyDown.
For example
Unfortunately that doesn't disable that ping sound.
thx in advance for any help.
When focus is on TextBox and we press ENTER or ESC then we will hear that sound. I'm trying to disable that. Did any one got that problem before ? I was trying to create my own SilentTextBox which will inherit from TextBox and disable that sound by overriding OnKeyPress. OnKeyDown, OnKeyUp and OnPreviewKeyDown.
For example
c Syntax (Toggle Plain Text)
protected override void OnKeyPress(KeyPressEventArgs e) { if ((e.KeyChar != 13) || (e.KeyChar != 27)) { base.OnKeyPress(e); } }
Unfortunately that doesn't disable that ping sound.
thx in advance for any help.
You can't disable it. "you can't" == you can but after huge efforts. what does this sound means to you?! it means you haven't accept button on your forum, once you've this button you won't get this sound + TextBox class not getting this sound itself, but OS does.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
•
•
Join Date: Aug 2009
Posts: 1
Reputation:
Solved Threads: 0
Your solution is correct, except that you should use because by using OR, when it's ENTER, it's not ESC, and the default handler is called (and vice-versa).
C# Syntax (Toggle Plain Text)
(e.KeyChar != 13) && (e.KeyChar != 27)
Last edited by tanioskahi; Aug 20th, 2009 at 9:49 am.
•
•
Join Date: Oct 2009
Posts: 1
Reputation:
Solved Threads: 0
0
#6 32 Days Ago
Last edited by pato212; 32 Days Ago at 1:27 pm.
•
•
Join Date: Jul 2009
Posts: 879
Reputation:
Solved Threads: 137
0
#7 32 Days Ago
C# Syntax (Toggle Plain Text)
// Stop the annoying BEEP when user presses ENTER or ESCAPE... protected override void OnKeyPress(KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Enter || e.KeyChar == (char)Keys.Escape) { e.Handled = true; // stop annoying beep } // call base handler... base.OnKeyPress(e); }
Last edited by DdoubleD; 32 Days Ago at 3:10 pm.
![]() |
Similar Threads
- getElementById not retreiving values from ASP textbox (JavaScript / DHTML / AJAX)
- Append the value to the text in the textbox using autocomplete (JavaScript / DHTML / AJAX)
- Popup window on button click (ASP.NET)
- .NET 3.5 CssClass bug on TextBox? (ASP.NET)
- How to Validate the Text in a TextBox (C#)
- Number Checking string input in Delphi? (Pascal and Delphi)
- Character limit in textbox (VB.NET)
- Clearing Hard Drive (Win Me) (Windows 95 / 98 / Me)
- How do you do a simple POS in VB .net (VB.NET)
Other Threads in the C# Forum
- Previous Thread: How to use set/get ??
- Next Thread: SQL Server Database Connection for a Clients-Server Application
| Thread Tools | Search this Thread |
.net access algorithm angle array asp.net barchart bitmap box broadcast c# capturing check checkbox client combobox control conversion csharp custom database datagrid datagridview dataset datetime dbconnection degrees delegate design development disappear draganddrop drawing encryption enum eventhandlers excel file firefox form format forms function gdi+ image index input install java label leak libraries list listbox loop mandelbrot math monodevelop mouseclick msword mysql operator path pause photoshop picturebox pixelinversion post programming radians regex remoting resourcefile richtextbox round server sleep socket sql statistics stream string table tcpclientchannel text textbox thread time timer update usercontrol validation virtualization visualbasic visualstudio webbrowser windows winforms wpf xml






