.Net ramblings
# Tuesday, 26 October 2004
TextBox.Focus() doesn't work within Form_Load

i have a windows form with a textbox inside a panel, and the following code doesn't work as expected:

private void WizardLoad(object sender, System.EventArgs e)
{
  this.txtUsername.Focus();
}

Thanks to someones post

i now know that the best way to do it is as follows:

this.ActiveControl = this.txtUsername;

It works!


Tuesday, 26 October 2004 12:06:57 (GMT Daylight Time, UTC+01:00)  #    Comments [1]  .Net Windows Forms