How do I put focus on a TextBox when a form loads? Ask Question

How do I put focus on a TextBox when a form loads? Ask Question

I have a TextBox in my C# program. I need focus to be on this TextBox when the program starts.

I tried this on Form_Load:

MyTextBox.Focus();

but it doesn't work.

How do I put focus on this when the form loads?

ベストアンサー1

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

this.ActiveControl = yourtextboxname;

おすすめ記事