Say I have a Textbox
nested within a TabControl
.
When the form loads I would like to focus on that textbox (by default the focus is set to the tabControl).
Simply calling textbox1.focus()
in the Load
event of the form does not appear to work.
I have been able to focus it by doing the following:
private void frmMainLoad(object sender, EventArgs e)
{
foreach (TabPage tab in this.tabControl1.TabPages)
{
this.tabControl1.SelectedTab = tab;
}
}
My question is:
Is there a more elegant way to do this?