How to set which control gets the focus on application start

落爺英雄遲暮 提交于 2019-11-27 01:45:06

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/2063603/how-to-set-which-control-gets-the-focus-on-application-start

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!