Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tab Key Functionality Using Enter Key in VB.Net

I have a form with nearly 20 Textbox and 5 Combobox and one control in dependent on the other, Now I want to write the code for the form in such a way that, Pressing Enter Key and Tab Key should have the same functionality.

Like on pressing Tab Key the focus moves to next control should also be performed when I press the Enter Key. Similarly when I press the Enter Key, there is some process code written in key press event but this should also be performed when I press the Tab Key.

like image 406
Kishore Kumar Avatar asked Dec 06 '11 21:12

Kishore Kumar


People also ask

How to set Enter Key as Tab Key in VB net?

How to make ENTER key working like TAB key in Windows Forms (WinForms) Application using C# and VB.Net. If KeyAscii = 13 Then ' The ENTER key. SendKeys. "{tab}" ) ' Set the focus to the next control.

What is key press in VB?

The KeyPress event occurs when the user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus. This event also occurs if you send an ANSI keystroke to a form or control by using the SendKeys action in a macro or the SendKeys statement in Visual Basic.


1 Answers

First Make your Form's Keypreview property= True And Then Paste The Code Below in Form's Keydown Event

 If e.KeyCode = Keys.Enter Then
    Me.SelectNextControl(Me.ActiveControl, True, True, True, False) 'for Select Next Control
End If
like image 108
Jordon Malik Avatar answered Sep 25 '22 13:09

Jordon Malik