After text has been entered in text box 1 and the enter key is pressed to make text box 2 active (the curser will jump from text box 1 to text box 2.
Are you trying to ask
"How do I make the cursor move from textbox1 to textbox2 when the user presses the enter key in textbox1?"
In textbox1 handle the KeyPress event something like this
- private void tbPassword_KeyPress(object sender, KeyPressEventArgs e)
-
{
-
if ((Keys)e.KeyChar == Keys.Enter) btnLogInRead_Click(this, EventArgs.Empty);
-
if ((Keys)e.KeyChar == Keys.Up) tbName.Focus();
-
if ((Keys)e.KeyChar == Keys.Right) btnLogIn.Focus();
-
}
-
In this example you can see 3 different actions that could take place:
If [Enter] is pressed it is the same as clicking the "LogInRead" button. This is where you might want to have it shift fields. Me personally, I always expect an enter key to press the default button on the form.
If the [Up] arrow key is pressed, then focus shifts to the "Name" textbox.
if the [right] arrow key is press, focus shifts to the LogIn button (but doesn't click it)