Windows 窗体中的 tabindex 行为是否有明确的指南?

发布于 2024-10-21 09:40:36 字数 156 浏览 3 评论 0原文

我维护一个基于 Windows 窗体的应用程序框架。我没有明确指定 Tab 键顺序的奢侈 - 控件是在运行时添加的,因此 Visual Studio 没有帮助。

Tab 键顺序,尤其是涉及容器时,是一个谜。是否存在描述 Windows 窗体在运行时如何管理 Tab 键顺序的资源?

I maintain an application framework based on Windows Forms. I don't have the luxury of specifying tab order explicitly - controls are added at runtime, so Visual Studio doesn't help.

Tab order, especially when containers are involved, is something of a mystery. Does a resource exist that describes how, at runtime, Windows Forms manages tabbing order?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

旧竹 2024-10-28 09:40:36

发布的答案不正确,Z顺序与制表符顺序无关。巧合的是,在窗体上放置控件的顺序也会以可预测的方式设置 z 顺序和 TabIndex 属性值。一旦您使用“格式”菜单将控件移动到前面或后面,它就会变得不正常。只有 TabIndex 很重要。直觉上:否则就不需要该财产了。

这里没有快捷方式,如果您无法使用设计器为您设置 TabIndex 属性,那么您必须自己设置它。你必须编写代码。通常并不那么困难,只需从最后使用的值开始按顺序分配它,按 Tab 键顺序添加控件即可。如果需要在使用设计器添加的控件之间插入指定的 TabIndex 值,请在指定的 TabIndex 值中保留间隙。

The posted answers are not correct, Z-order has nothing to do with tab order. It is just a coincidence that the order in which you drop controls on a form also sets the z-order and the TabIndex property value in a predictable way. It gets out of whack as soon as you use the Format menu to move controls to the front or back. Only TabIndex matters. Intuitively: there wouldn't be a need for the property otherwise.

No shortcuts here, if you can't use the designer to set the TabIndex property for you then you have to set it yourself. You have to write the code. It isn't typically that difficult, just assign it sequentially from the last used value, add the controls in tabbing order. Leave a gap in assigned TabIndex values if you need to insert them between controls that you added with the designer.

拒绝两难 2024-10-28 09:40:36

我想MSDN有权威指南< /a>.

同样重要的是: UpdateZOrder,正如 @jswolf19 的评论所指出的。

I would imagine that MSDN has the definitive guide.

Also important: UpdateZOrder, as pointed out in the comments by @jswolf19.

一个人的旅程 2024-10-28 09:40:36

选项卡索引设置为创建事物的顺序。但无论如何,您都可以在运行时指定选项卡索引,因此在获得所需的行为时不会有任何问题。

Tab index is set as the order in which things are created. But you can specify tab index at runtime anyway so you shouldn't have any problems in getting the behaviour you want.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文