多个面板和组框以及选项卡顺序维护

发布于 2024-07-26 20:53:44 字数 2003 浏览 6 评论 0原文

我有一个由我的老板设计的 VB.NET (2005) 应用程序,它使用 100 多个输入和显示控件(文本框、组合框等),其中许多都带有关联的标签。 我的老板要求我设置 Tab 键顺序,然后捕获按键,以便用户可以使用 Enter 来导航控件。 我有 2 个这样的应用程序可以使用。

对于 Tab 键顺序,我无法使用 View/TabOrder 功能,因为显示了很多蓝色的小 tabindex 弹出窗口,我看不到表单上的任何可单击的控件。 我尝试单击“通过”弹出窗口并取得了一些成功,但它仍然没有给我我想要的选项卡顺序。 CodeSMART 附带的选项卡助手也没有给我想要的结果,所以我可以使用它。

此用户控件上的控件分布在许多组中,而这些组又分布在多个拆分容器面板中。 主 splitcontainer 中的第一个面板有 3 个主组框,可通过工具条按钮进行选择(将所需的组框设置为可见,并将其他组框设置为不可见。)

示例:

Private Sub ShowMainPanel()
    'Note: Panels are groupboxes
    Me.MaterialPanel.Visible = False
    Me.HaulPanel.Visible = False
    Me.MainPanel.Visible = True

End Sub

每个组框都包含更多组框,每个组框包含 1 到 15 个组框控制。 有些是只读的,但其他的则需要用户提供信息。 所需控件的制表位设置为 true。

因此,我手动将每个主组面板选项卡索引设置为 0 到 2。然后,对于第一个组框(主面板),我为其包含的每个控件和组框设置选项卡索引。 非容器类型控件的选项卡索引设置为 0 到 25,然后主面板上的组框(子组)为 26 到 48。然后,我转到这些子组中的每个控件,并为这些控件设置选项卡索引,从0 到 Control.count-1 为该组。

总之,我的 Tab 键顺序如下所示(缩写):

mainPanel = 0
  1st fields = 0.0
  2ndfield = 0.1
  3rd field = 0.2
  1st group = 0.3
    1st field in 1st grp1 = 0.3.0
    2nd field in 1st grp1 = 0.3.1
  2nd group = 0.4
    1st field in 1st grp2 = 0.4.0
    2nd field in 1st grp2 = 0.4.1
materialPanel = 1
  1st fields = 1.0
  2ndfield = 1.1
  3rd field = 1.2
  1st group = 1.3
    1st field in 1st grp1 = 1.3.0
    2nd field in 1st grp1 = 1.3.1
  2nd group = 1.4
    1st field in 1st grp2 = 1.4.0
    2nd field in 1st grp2 = 1.4.1

注意:例如,我实际上并未输入 1.4.0 作为 tabindex,而是为控件输入 0,为子组输入 4,为主组输入 1。

然后,我根据选项卡顺序通过“文档大纲”面板设置 zorder。

完成所有这些后,我终于能够获得我想要在主面板上工作的选项卡顺序。

但是,当我将相同的方法应用于其他 2 个分组框(materialPanel 和 haulpanel)时,选项卡完全被忽略。 选项卡在应用程序中根本不起作用。 对于第二个到主组框(MaterialPanel 和 HaulPanel)。 该应用程序是控制库,因此我在调试时使用内置的 UserTestContainer,并且当显示第 2 个组框之一时,Tab 键将焦点从应用程序移出并移入测试容器。

在第一个组框(MainPanel)上时不会发生这种情况。 效果很好。

把这些东西摆出来花了我大约 3-4 个小时的时间,这是一项乏味的工作。 由于控件数量较多,该应用程序很难使用,因为只要对表单设计器进行更改,就需要 15-20 秒的时间来处理它。

有人知道这里发生了什么吗?

I have a VB.NET (2005) application designed by my boss that uses a over 100 input and display controls (textboxes, comboxes, etc.), many with labels associated. My boss asked me to set the tab order, and then trap keypress so the user can use enter to navigate controls. I have 2 apps like this to work on.

For the tab order, I could not use the View/TabOrder feature, since there are so many blue little tabindex popups showing, that I can not see any of the controls on the form to click. I tried clicking 'through' the popup with some success, but it still did not give me the tab order I wanted. The tab assistant that came with CodeSMART did not give me the result I wanted, either, so I could use it.

The controls on this usercontrol are spread among many groups, which in turn are spread among several splitcontainer panels. The 1st panel in the main splitcontainer has 3 main groupboxes which are selected via a toolstripbutton ( which sets the desired groupbox to visible and turning the others to invisible.)

Example:

Private Sub ShowMainPanel()
    'Note: Panels are groupboxes
    Me.MaterialPanel.Visible = False
    Me.HaulPanel.Visible = False
    Me.MainPanel.Visible = True

End Sub

Each of these groupboxes contain more groupboxes, each of which contain 1 to 15 controls. Some are read only, but others need information from the user. The required controls have their tab stop set to true.

So I MANUALLY set each of the main group panels tabindexes as 0 thru 2. Then for the 1st groupbox(mainpanel), I set the tabindex for each of it's controls and groupboxes that are contained within. The non-container type controls have their tabindexes set to 0 thru 25, and then the groupboxes (sub groups) on the mainpanel are 26 thru 48. I then went to each control in these sub groups and set tab index for those controls starting at 0 thru Control.count-1 for the group.

In summary, my tab orders look like this (abbreviated):

mainPanel = 0
  1st fields = 0.0
  2ndfield = 0.1
  3rd field = 0.2
  1st group = 0.3
    1st field in 1st grp1 = 0.3.0
    2nd field in 1st grp1 = 0.3.1
  2nd group = 0.4
    1st field in 1st grp2 = 0.4.0
    2nd field in 1st grp2 = 0.4.1
materialPanel = 1
  1st fields = 1.0
  2ndfield = 1.1
  3rd field = 1.2
  1st group = 1.3
    1st field in 1st grp1 = 1.3.0
    2nd field in 1st grp1 = 1.3.1
  2nd group = 1.4
    1st field in 1st grp2 = 1.4.0
    2nd field in 1st grp2 = 1.4.1

Note: I did not actually enter, for instance, 1.4.0 for a tabindex, but 0 for the control, 4 for the sub group and 1 for main group.

I then set the zorder via the Document Outline panel in based on the tab order.

Once I did all of this I was finally able to get the tab order I wanted to work for the mainpanel.

But when I applied the same to the other 2 groupboxes (materialPanel and haulpanel), the tabs are completely ignored. Tab does not work at all within the app. for the 2nd to main groupboxes (MaterialPanel and HaulPanel). The app is Control Library so I use the built in UserTestContainer when debugging, and when one of the 2nd 2 groupboxes are showing, the tab key moves the focus out of the app and into the test container.

This does not happen when on the 1st groupbox (MainPanel). It works fine.

Setting this stuff out took me about 3-4 hours to tedious work. Due to the number of controls, this application is hard to work with, as anytime a change is made to the form designer, it takes a good 15-20 seconds to process it.

Does anyone have a clue about what's going on here?

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

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

发布评论

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

评论(2

小…楫夜泊 2024-08-02 20:53:44

听起来 GroupBox 被分配了表单上的最后一个选项卡索引,因此输入焦点的下一个可行选项是表单本身,在本例中是测试容器。

您可以捕获 KeyPreview 事件吗? 取消按键,然后仅使用内部维护的控件顺序集合来给予焦点。 考虑到控件的数量,无论如何,您似乎都应该在代码中完成大部分操作。 如果您使用 Groupbox/Panel 的 .Controls 属性并通过迭代该集合并找到所需的确切控件来处理焦点,维护将会容易得多。

It sounds like the GroupBoxes are being assigned the last tab index on the form so the next viable option for input focus is the form itself, which is the test container in this case.

Can you just capture the KeyPreview event? Cancel the key press and then just use an internally maintained collection of the order of controls to give focus. Given the number of controls it seems like you should be doing most of this in code anyway. Maintenance will be much easier if you use the .Controls property of the Groupbox/Panel and handle focus by iterating over that collection and finding the exact control you want.

物价感观 2024-08-02 20:53:44

我无法使用 View/TabOrder 功能,因为显示了太多蓝色的小 tabindex 弹出窗口,我看不到表单上的任何可单击的控件。

这是您可能想要手动编辑 *.designer.vb 文件的极少数情况之一。 设计器文件是在 Visual Studio 表单编辑器中生成的,并且包含用于创建和设置表单中所有控件的初始属性的代码。 通常,您真的不想触及此文件,但如果您可以通过视觉设计器获取它们,这可能是下一个最佳选择。

I could not use the View/TabOrder feature, since there are so many blue little tabindex popups showing, that I can not see any of the controls on the form to click.

This is one of the rare cases when you may want to edit the *.designer.vb file by hand. The designer file is generated the Visual Studio forms editor, and has code creating and setting the initial properties of all the controls in a form. Normally you really don't want to touch this file, but if you can get at them via the visual designer this might be the next best option.

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