I'm trying to force ENTER key to act like TAB key

sizer

Centurion
Joined
Mar 6, 2003
Messages
123
Location
Croatia
Can anyone help me!
I'm trying to force ENTER key to act like TAB key ,but when
my cursor enters combobox and I press ENTER then cursor jumps to third control (instead second)!


Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean

Dim ctl As Control = Me.ActiveControl


If keyData = keyData.Enter Then
MessageBox.Show(keyData) ' keyData is 13 13 when ENTER is pressed on ComboBox
Me.SelectNextControl(ctl, True, True, True, True)

End If

End Function
 
Are your TabIndex set up correctly? The tabs only follow the order
that the controls' TabIndexes are set to. If the third control has
the TabIndex of '2' and the first control of '1', then the order of
tab will be first control -> third control. You need to change it manually.

Click 'View -> Tab Order...' to go into TabIndex setting mode, where
you can click the controls in the order that you want them.
 
This is a function, so you need to Return True to indicate that the
key was handled.

Your If statement should look like this:
Visual Basic:
If keyData = keyData.Enter Then
  MessageBox.Show(keyData) ' keyData is 13 13 when ENTER is pressed on ComboBox
  Me.SelectNextControl(ctl, True, True, True, True)

  Return True
End If
 
Back
Top