Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

KeyPress on NumericUpDown

Status
Not open for further replies.

jrl237

IS-IT--Management
Jan 29, 2002
61
US
I hope someone has run into this before and has a solution.

I have a Windows Form that contains several textboxes and comboboxes. I want the user to be able to quickly navigate through the form, so pressing ENTER in each control skips to the next control. Everything works fine, except for the one numericupdown control I have. It works properly (focus is shifted on ENTER) but it emits a DING every time, as though the keypress wasn't being handled and the ENTER was being passed to the control.

I know this will be quite annoying to the user.

Here's the code I'm using. It seems to work for everything else:

Code:
  Private Sub nudQuan_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles nudQuan.KeyDown
    bKeyHandled = False
    If e.KeyCode = 13 Then
      bKeyHandled = True
      txtLocation.Focus()
    End If
  End Sub

  Private Sub nudQuan_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles nudQuan.KeyPress
    e.Handled = True
  End Sub

Any help would be greatly appreciated.

jrl
 
Why not :

Private Sub NumericUpDown1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles NumericUpDown1.KeyPress
If e.KeyChar = Microsoft.VisualBasic.Chr(13) Then
SendKeys.Send(vbTab)
End If
End Sub


Eric De Decker
Visit The Belgium "Visual Basic Group" at
 
Same result. It works to move the focus, but it dings like the ENTER keycode is getting passed to the control.
 
The question is, why does Windows pass the ENTER keycode to the numericupdown control when e.handled is set to true in the keypress event? It doesn't do this on textbox or comboboxes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top