Link to home
Start Free TrialLog in
Avatar of Alberto071397
Alberto071397

asked on

How to jump to the next control by using the ENTER key

Let's have a form with several text boxes. The tab order has been set as needed and is working as expected. After the user fills each text box, the tab key moves the focus to the next text box and so on. I need suggestions on what would be the most convenient method to allow the user to go to the next text box by using the ENTER key as an alternate key?
Avatar of 123654789987
123654789987

ASKER CERTIFIED SOLUTION
Avatar of sumix
sumix

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bob Learned
I like the SendKeys.SendWait with the {Tab} key the best, then you don't need to specify a control to focus to.

Bob
This is what I use:

  private void textBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
    {
      if (e.KeyCode == Keys.Enter)
      {
        SendKeys.SendWait("{Tab}");
        e.Handled = true;
      }
    }

Bob