Tab index does not work with controls in panels?

2019-04-26 01:38发布

I have a vb.net windows form with about 15 comboboxes and 15 textboxes, along with several other controls. All of these TextBoxes and ComboBoxes are located in panels. The reason for this is I need to adjust the visible property of controls based upon what the user selects/enters, so grouping each label and control together in their own panels seemed like an easy way to accomplish this.

I've set the tab order via properties, but it doesn't work. When I tab through my form, it skips around and does not follow the tab order that I've set. Is this because my controls are each located in separate panels? I've set TabStop to false for everything I don't want a tabstop on, I'm a little confused about what's going on here. It really seems that the fact that my ComboBoxes and TextBoxes are each inside their own panels is preventing my tab indices to work. Can anyone confirm this or have other ideas of what may be happening? TabIndex works if I create a new form.

4条回答
我欲成王,谁敢阻挡
2楼-- · 2019-04-26 02:17

Setting TabStop to FALSE means it will skipped by when its turn comes in the Tab Order. Normally you would set TabStop for LABELs to FALSE and all other INTERACTIVE Controls to TABSTOP = True (unless the control is disabled off course).

Dont skip from Tab to Tab. Your TabStop and Tab Order ought to be something like the list below.

Name         Parent        TabOrder        TabStop
=======================================================
Form         -             0               -
TabStrip1    Form          1               True
Tab1         TabStrip1     2               True
Label1       Tab1          3               False
Textbox1     Tab1          4               True
Label2       Tab1          5               False
Combo1       Tab1          6               True

Tab2         TabStrip1     7               True
Label3       Tab2          8               False
Textbox2     Tab2          9               True
Label4       Tab2          10              False
Combo2       Tab2          11              True

Tab3         TabStrip1     12               True
Label5       Tab3          13               False
Textbox3     Tab3          14               True
Label6       Tab3          15               False
Combo3       Tab3          16               True
查看更多
倾城 Initia
3楼-- · 2019-04-26 02:17

I have found that you have to look at EVERY tab index for each control and grouping of controls (group box, panel, whatever). Unlike Classic VB, .Net doesn't update all the other tab indices for you. You can have as many controls as you want with the same tab index on a form, panel, or other grouping type.

BTW, for those that posted the View - Tab Order menu item, thank you. I didn't know it was there and it helped me immensely to properly order a form I have with multiple nested group boxes. This was an excellent tool for reviewing the tab order. If you use this, be sure to pay attention to each level of nesting.

查看更多
来,给爷笑一个
4楼-- · 2019-04-26 02:29

Believe it or not, the panel ordering absolutely DOES affect the TabIndex. I have found that the easiest way to deal with tab ordering on a multi-panel form is to use View>Tab Order as suggested by LarsTech. Then once the tab ordering is visible, you'll be able to see how the panels affect the overall ordering of the controls contained in each panel. Next, left-click one at a time on the actual panels, in the order that you want the flow to go. You'll notice that it will then automatically sub-order the controls inside each panel, with the overall panel ordering be in the order that you specified. Once this is done you can then click on each control inside each panel to set a control's relative tab order inside a given panel.

查看更多
叼着烟拽天下
5楼-- · 2019-04-26 02:34

Try using "View - Tab Order" in the Visual Studio designer and click each container and control in the order you want. The tab index of the parent container (panels) matters.

查看更多
登录 后发表回答