How to set which control gets the focus on application start

后端 未结 1 1055
無奈伤痛
無奈伤痛 2020-12-09 01:27

For a C# Windows Forms application, how do I set the default focus to a given control when my application starts?

相关标签:
1条回答
  • 2020-12-09 02:02

    The one with the minimum tab index automatically gets the focus (assuming the TabStop property 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 Select method when the form loads.

    0 讨论(0)
提交回复
热议问题