I\'m facing a little problem I can\'t seem to solve. The problem is in an WinForm I have several containers (TabControls, Panels, ...).
The Tab-order within the controls
You could work with the Leave event of that Control, and manually set focus in the code behind to do this.
private void textBox1_Leave(object sender, System.EventArgs e)
{
textBox2.Focus();
}
If you want to use the TAB key, it's better to not use the Leave event
It will create some bad redirections if you change with your mouse for example.
Better override ProcessCmdKey
Here is a good solution :
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
bool baseResult = base.ProcessCmdKey(ref msg, keyData);
//if key is tab and TextBox1 is focused then jump to TextBox2
if (keyData == Keys.Tab && TextBox1.Focused)
{
TextBox2.Focus();
return true;
}
else if (keyData == Keys.Tab && TexBox2.Focused)
{
TextBox3.Focus();
return true;
}
return baseResult;
}
Hope it helped.