Use "Enter" to "Tab"

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Doug Bell

    Use "Enter" to "Tab"

    Hi,
    I have just built a small application with a form that has one Text Box and
    one Check Box and a couple of Command Buttons.

    What I am trying to achieve is that if the Text Box has focus and the User
    hits the "Enter" button the focus will move to the next Tab item (i.e. the
    Check Box). Likewise on the Check Box but obviously if a Command Button has
    the focus, it will initiate the Click event

    I have set the Forms CancelButton to the button that closes the form and I
    have its AcceptButton set to none.

    Do I have to trap every keystroke and test for "Enter"? Or is there a
    property that I am missing?

    Thanks

    Doug


  • Ken Tucker [MVP]

    #2
    Re: Use "Enter&quo t; to "Tab&qu ot;

    Hi,


    Set the forms keypreview property to true.

    Private Sub Form1_KeyDown(B yVal sender As Object, ByVal e As
    System.Windows. Forms.KeyEventA rgs) Handles MyBase.KeyDown

    If e.KeyCode = Keys.Enter Then

    Me.SelectNextCo ntrol(Me.Active Control, True, True, True, True)

    End If

    End Sub



    Ken

    -----------------


    "Doug Bell" <dug@bigpond> wrote in message
    news:eY%236kFQo EHA.596@TK2MSFT NGP11.phx.gbl.. .
    Hi,
    I have just built a small application with a form that has one Text Box and
    one Check Box and a couple of Command Buttons.

    What I am trying to achieve is that if the Text Box has focus and the User
    hits the "Enter" button the focus will move to the next Tab item (i.e. the
    Check Box). Likewise on the Check Box but obviously if a Command Button has
    the focus, it will initiate the Click event

    I have set the Forms CancelButton to the button that closes the form and I
    have its AcceptButton set to none.

    Do I have to trap every keystroke and test for "Enter"? Or is there a
    property that I am missing?

    Thanks

    Doug



    Comment

    Working...