如何设置哪个控件将重点放在应用程序启动上 [英] How to set which control gets the focus on application start

查看:58
本文介绍了如何设置哪个控件将重点放在应用程序启动上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于C#Windows Forms应用程序,如何在应用程序启动时将默认焦点设置为给定控件?

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

推荐答案

具有最小制表符索引的索引会自动获得焦点(假设 TabStop 属性设置为true)。只需适当地设置选项卡索引即可。

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.

Visual Studio提供了一种方法,只需按所需顺序单击控件即可轻松设置选项卡索引。在表单设计视图中时,可以通过在视图菜单中选择制表顺序选项来激活此功能。

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.

您还可以手动将焦点移至窗体加载时调用其 Select 方法的控件。

You can also manually give the focus to a control by calling its Select method when the form loads.

这篇关于如何设置哪个控件将重点放在应用程序启动上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆