I want to detect when tab key is pressed in a textBox and focus the next textbox in the panel.
I have tried out keyPressed method and keyDown method. But when I run the program and debug those methods are not calling when the tab key is pressed. Here is my code.
private void textBoxName_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Tab)
{
textBoxUsername.Focus();
}
}
private void textBoxName_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar==(char)Keys.Tab)
{
textBoxUsername.Focus();
}
}
Please correct me.Thank you.