We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

using enter key to tab to numericupdown controls causes error sound

I have a form that has a bunch of numericupdown controls. I would like the user to be able to use the enter key to tab to each control. However whenever the user does this the computer beeps an error sound.

I have looked at other posts and the only thing I could find is references to a textbox instead of a numericupdown control. They suggests that I use the e.Handled = True in the keypress event to get rid of that. However this does not work. Do I have to do something different with a numericupdown control?

Here is a copy of the code that I am using.

Private Sub UpDown9am_KeyPress(ByVal sender As Object, ByVal e As KeyPressEventArgs) Handles UpDown9am.KeyPress
If e.KeyChar = ChrW(Keys.Return) Then
SendKeys.Send("{TAB}")
e.Handled = True
End If
End Sub

I am using vb.net in visual studio 2005 on an XP machine.

1 Reply

GR gruu September 18, 2007 11:35 AM UTC

Hi Ben,

It's working fine when I use SendKeys.SendWait() methos instead of SendKeys.Send() method. Here is the code snippet,

Private Sub NumericUpDown1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles NumericUpDown1.KeyPress
If e.KeyChar = ChrW(Keys.Return) Then
SendKeys.SendWait("{TAB}")
e.Handled = True
End If
End Sub

Please let me know if its working for you.

Good Luck

Loader.
Live Chat Icon For mobile
Up arrow icon