Thursday, 22 March 2018

Go to next control by pressing Enter Key in c# winform application

Description : In this post go to next control using Enter Key in c# windows application

- Add 2 Textbox in winform

- Generate KeyDown event of both textbox control

- Add Below code in both keydown event

private void textbox1_KeyDown(object sender, KeyEventArgs e) 
{
    if (e.KeyCode == Keys.Enter) 
        textbox2.Focus(); 
}

private void textbox2_KeyDown(object sender, KeyEventArgs e) 

    if (e.KeyCode == Keys.Enter) 
        textbox1.Focus(); 
}

Note : if focus in textbox 1 than press enter and change focus in textbox2 if again press enter than focus set in textbox1

No comments:

Post a Comment