make ENTER key act like TAB key - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

make ENTER key act like TAB key

apenticoffapenticoff Posts: 63Member
Is there a simple way to make the ENTER key act just like the user pressed the TAB key? I have searched but not found a simple solution yet. Thanx, Art

Comments

  • GogiGogi Posts: 258Member
    : Is there a simple way to make the ENTER key act just like the user pressed the TAB key? I have searched but not found a simple solution yet. Thanx, Art
    :


    Yes,there is a way. ;-)

    Set KeyPreview property of your Form to True.
    And use this code for your Form_KeyDown event:

    [code]
    Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
    If e.KeyCode = Keys.Return Then
    SendKeys.Send("{TAB}")
    End If
    End Sub
    [/code]

    Hope this helps!
  • apenticoffapenticoff Posts: 63Member
    : : Is there a simple way to make the ENTER key act just like the user pressed the TAB key? I have searched but not found a simple solution yet. Thanx, Art
    : :
    :
    :
    : Yes,there is a way. ;-)
    :
    : Set KeyPreview property of your Form to True.
    : And use this code for your Form_KeyDown event:
    :
    : [code]
    : Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
    : If e.KeyCode = Keys.Return Then
    : SendKeys.Send("{TAB}")
    : End If
    : End Sub
    : [/code]
    :
    : Hope this helps!
    :
    You da man! Thanks a bunch. It took 2 minutes to load and run your code. Worked perfectly. I had spent hours looking for the answer. Thanks, Art
Sign In or Register to comment.