10-26-2009 02:40 PM
When using a numberic edit and typing in a number followed by the "Enter" key the sound card will beep. Is there a way to prevent this behavior?
Solved! Go to Solution.
10-27-2009 06:39 PM
UmmGooD,
What do you mean by a numeric edit? Where/how are you getting this item?
10-28-2009 08:00 AM
It is the NumericEdit control available in Measurement Studio. When a user types in a number then presses enter the control will cause a 'Beep' which has received complaints from customers. I would like to figure out a way to stop this behavior.
Here is the full name:
NationalInstruments.UI.WindowsForms.NumericEdit
10-29-2009 12:49 PM
UmmGooD,
This is not a Measurement Studio thing it is a Visual Studio problem. Basically the beep for pressing the enter button is because you have not configured an Accept Button or a button to take the default enter action. The simplest way to "fix" this is to drop down a button set visible to False (or just use a button you already have). Now go to your forms properties and set this button as the accept button. If you are looking for a much more "complete" solution including handling the ESC key I would recommend you check out this external forum.
11-13-2009 11:11 AM
11-16-2009 04:13 AM
Hi UmmGooD,
When you configure an Accept button for the form, the enter button will be handled by the form to raise the Accept button's event handler. The Value in the NumericEdit is not updated and hence the AfterChangeValue is not raised. But changing focus out of the NumericEdit after changing the value should raise the AfterChangeValue event.
Another way to remove the beep without the above disadvantage is by creating an event handler for the keypress event on the NumericEdit and setting the Handled value of the KeyPressEventArgs to true when 'Enter' is pressed.
private void NumericEdit1_KeyPress(object sender, KeyPressEventArgs e)
{
// Form has no AcceptButton - prevents default beep on hitting enter
if (e.KeyChar == 13)
{
e.Handled = true;
}
}