For a C# Windows Forms application, how do I set the default focus to a given control when my application starts?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The one with the minimum tab index automatically gets the focus (assuming the
TabStopproperty is set to true). Just set the tab indices appropriately.By the way, Visual Studio provides a way to easily set tab indices by just clicking on the controls in the order you want. You can activate this feature by choosing “Tab Order” option in the “View” menu when you are in the form design view.
You can also manually give the focus to a control by calling its
Selectmethod when the form loads.