VB.NET 限制选项卡排序吗?

发布于 2024-10-05 08:46:40 字数 309 浏览 0 评论 0原文

我继承了一个弗兰肯斯坦 VB6“转换”为 VB.NET winform 应用程序。该应用程序中有大量字段,用户理所当然地抱怨 Tab 键顺序已关闭(在某个点之后,它开始在整个表单上跳跃)。

发现选项卡顺序中的某些内容已关闭,我进去并打开“查看”>“ Tab 键顺序,看起来不错。

可以肯定的是,我再次刷新了表单,当我处于选项卡顺序视图时,一切都很好,但是当应用程序运行时,它仍然开始像以前一样在同一区域跳跃?!有其他人遇到过这种情况吗?如果遇到的话,您是如何解决的?

[编辑]:这些输入表单都位于选项卡控件内的单独选项卡上,这可能会使情况更加混乱。

I have inherited a frankenstein VB6 "Converted" to VB.NET winform application. This application has a metric ton of fields in it, the users rightfully complained that the tab order is off (after a certain point it starts jumping all over the form).

Figuring something in tab order was off, I went in and turned on View > Tab Order and it looked good.

To be sure I went through the form again fresh and when I'm in tab order view all is well, but when the app runs it still starts jumping around the same area as before?! Has anyone else encountered this and how did you resolve if you did?

[Edit]: These input forms are all on separate tabs within a tab control, which probably muddies the situation even more.

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

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

发布评论

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

评论(3

素染倾城色 2024-10-12 08:46:40

代码中是否存在任何奇怪的 Focus 调用,这些调用会覆盖 Tab 键顺序并手动设置应用程序的焦点?

过去,我遇到过标签排序混乱的问题,我通常只是从头开始浏览应用程序,然后自己手动设置顺序。我意识到这很可能不是您正在寻找的东西,但我不知道还有什么

Are there any strange Focus calls in the code that are overriding the tab order and setting the focus of the application manually?

I've had problems in the past with tab ordering getting itself all confused and I've usually just resorted to going through the application from scratch and setting the order myself manually. I realise that this may well not be what you are looking for but I don't know of anything else

懒猫 2024-10-12 08:46:40

如果表单上有许多控件,那么它们很可能是用面板和组框等容器组织的。设置 Tab 键顺序时,您还必须考虑容器的顺序。容器中选项卡顺序之间的不一致可以解释奇怪的跳跃。特别是如果两个或多个控件/容器具有相同的选项卡顺序值(这使得选项卡过程任意),则可能会发生这种情况。

解决方案思路:当然,更新和纠正 Tab 键顺序是一项缓慢且容易出错的工作。您可能需要编写一个例程,以递归方式迭代表单的容器和控件并正确分配选项卡顺序值。您可以通过比较容器的每个控件的位置点来设置选项卡顺序,其中最顶部和最左侧的点是“较低”等级,底部、最右侧的组件是“最高”等级。这当然需要一个自定义排序算法。如果你环顾四周,类似的东西可能已经存在了。

解决方案想法 2: 重构!分而治之。这将需要一些时间,但如果您将 UI 组件移动到单独的、按逻辑组织的用户控件中,您将获得更紧凑的代码库。您还会发现很多错误!

If you have many controls on a form chances are that they are organized with containers such as panels and group boxes. When setting the tab order you have to consider the order of the containers as well. An inconsistency between tab orders on in the containers could explain the weird jumping. This can happen especially if two or more controls/containers have the same tab order value which makes the tabbing process arbitrary.

Solution Idea: Of course updating and correcting the tab order is slow, error-prone work. It may behoove you to write a routine that iterates through the form's containers and controls recursively and assigning tab order values properly. You would set the tab order by comparing the Location point of each control of the container where top and left most point is the "lower" rank and the bottom, right-most component is the "highest". This would of course need a custom sorting alg. And if you look around, something like this may already be out there.

Solution Idea 2: Refactor! Divide and conquer. It will take some time but if you move the UI components into separate, logically-organized user controls you'll get tighter of the codebase. You'll also uncover a lot of bugs!

你丑哭了我 2024-10-12 08:46:40

有可能,您的某些控件嵌入在容器控件中,并且容器控件的 Tab 键顺序导致焦点看起来好像在随机跳跃。确保当您处于 Tab 键顺序视图中时,请特别注意容器控件的 Tab 键顺序:确保它们都没有相同的 Tab 键顺序,并且它们按照 Tab 键顺序按逻辑顺序排序您的个人控制。

否则,您需要检查 UI 代码中是否有对 Control.Focus 可能会干扰运行时的默认 Tab 键顺序。某些验证代码可能会在成功完成后将焦点更改为“下一个”控件(或者如果验证失败,则“返回”到上一个控件)。

Chances are, some of your controls are embedded in container controls, and the tab order of your container controls is causing the focus to appear as if it is jumping around randomly. Make sure that when you're in the tab order view, you pay careful attention to the tab order of your container controls: Make sure that none of them have the same tab order, and that they're ordered logically with the tab order of your individual controls.

Otherwise, you need to check your UI code for some calls to Control.Focus that could be interfering with the default tab order at run-time. Some validation code may be changing the focus to the "next" control after it completes successfully (or "back" to a previous control if validation failed).

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