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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With