How to set focus to a text box on windows form load?

W

Walter

I want to set focus to a text box on a C# windows form when the form loads.
How can I do this? I want the cursor to be in this text box when the form
loads so the user can just start typing. Below is what I have so far:

private void County_Load(object sender, EventArgs e)
{
txtCounty.Focus();
}

Thanks for the help
 
W

Walter

Bear with me as I am new to C# (been a DBA for 10 years). How would I do
that in the show event? Thanks.
 
J

Jeff Johnson

I want to set focus to a text box on a C# windows form when the form loads.

Make the text box the first item in the tab order. Or, more specifically,
the first focusable item in the tab order. Hopefully there's a label in
front of the text box with an accelerator, so make its tab index 0 and the
text box 1.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top