Textbox beeping when pressing enter key, tried e.Handled=true but does not fix this!

Posted on 2005-04-04
Medium Priority
Last Modified: 2008-02-01
Here the code snippet after trying hard to get rid of the beeping and removing \r\n key entry when multiline=true (as way of getting rid of the beep). Is there better way for entering numberic data into box than the textbox...it seem strange that textbox nor  richtextbox does not have event feature when entry is completed (via return key or unfocused). What is the best entry box in the world?.

Here the code snippets, I found it does not immediently generates beep until end of the program, is there way of disabling that but keep beep for other code?.

private void Agl_Set_Amp_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
                  if (e.KeyCode==Keys.Enter)
                        e.Handled=true;                                    //will not work to remove the beep!
                        string datas=Agl_Set_Amp.Text.Trim();      //remove space
                        datas.Trim('\r');                                    //this will not work well since it won't remove it in the middle !! investigating alternative method.
                        int datai=Tools.ConversionStringtoInterger(datas);  //contain try and exception trap (via interface) for non numberic data (System.Convert.Int32(string datas)).
                        if (datai==-975579)                                              //the chance of having same value is very very very tiny, hence use this as error...assumed!
                              double dataf=Math.Round(myAgl.VoltageAmp*1000);  //restore value if data invalid.
                              double dataf = System.Convert.ToDouble(datai); //convert interger into float
                              myAgl.AglVert_F_Ampitude("SET");                   //Program instrument via interface protocol (seperates class).
                              AglOut_Refresh_Active_Channel_Display();        //Update display.
Question by:riscy
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Author Comment

ID: 13704400
Note that the update display  AglOut_Refresh_Active_Channel_Display();  does not cause beep sound!

Accepted Solution

RomanPetrenko earned 1000 total points
ID: 13705149
Put e.Handled=true into KeyPress Handler but not in KeyDown, because KeyPress cause this annoying beep.
private void Form1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
  if (e.KeyChar == 0x0d) //Enter key pressed
    if (this.ActiveControl is TextBox) //don't beep only for textbox
      e.Handled = true;
====end of sample===

Author Comment

ID: 13714036
Thank that seem to fix problem...only from the keypress event.

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question