Question How to use ENTER as Tab between Textboxes..

Rexy

Member
Joined
Jan 16, 2007
Messages
14
Programming Experience
1-3
Hi.. I have a numbers of TextBoxes where we enter some numbers..

I enter a number then press TAB then enter a numer then press TAB and so on..

But how to Use Enter as TAB, so i can do it like this:
Enter a number press ENTER enter a number press Enter and so on..
 
In the KeyUp event of the textbox's you'll need to detect the enter key:
VB.NET:
Private Sub TB_KeyUp (...) Handles TB.KeyUp
  If e.KeyCode = Keys.Enter Then 
    'Enter key was pressed
  End If
End Sub
Next you'll need to either manually set focus to the next textbox (in case you don't want it to follow the tab order) or you simply move to the next control in the tab order (which would conveniently give you the ability to tie all of the textbox's KeyUp events into the single sub routine). Here's the code to select the next control in the tab order
VB.NET:
Me.SelectNextControl(CType(sender, TextBox), True, True, True, True)
 
Back
Top