Q. How can I set the focus on a text field based upon input criteria, instead of manually clicking in desired field or tabbing over to it?

Asked by reader. Answered by the Wonk on November 18, 2002

A.

You can do this using the ActiveControl property of the Form or Control class. For example, the following Load event handler sets the active control to be the second TextBox on the Form instead of the first TextBox control:

 

void Form1_Load(object sender, EventArgs e) {

  this.ActiveControl = textBox2;

}

Feedback

I have feedback on this Ask The Wonk answer