how to put focus on TextBox when the form load?

Gali picture Gali · Jul 6, 2011 · Viewed 282.5k times · Source

I have in my C# program textBox

I need that when the program start, the focus will be on the textBox

I try this on Form_Load:

MyTextBox.Focus();

but it wont work

Answer

V4Vendetta picture V4Vendetta · Jul 6, 2011

Set theActiveControl property of the form and you should be fine.

this.ActiveControl = yourtextboxname;