更多控件具有相同 tabindex 时的 Tab 键顺序?
Tab order when more controls have the same tabindex?
当更多控件具有相同的 tabindex
属性 时,是什么决定了 Tab 键顺序?
例如,将文本框添加到空表单后,文本框的 tabindex
为 0。通过复制文本框(Ctrl + 鼠标拖动),新文本框也有 tabindex
0。然后我添加了一个按钮,它的 tabindex
是 1.
在 运行 程序之后,焦点在第二个文本框上。
然后我将按钮的 tabindex
更改为 0,因此之后所有控件都具有 tabindex
= 0,并且在 运行 程序之后焦点位于最后添加的按钮上。
这是否意味着在多个控件具有相同 tabindex
属性 的情况下,Tab 键顺序将与添加 控件的顺序相反 到表格?似乎共享相同 tabindex
的控件的 Tab 键顺序 与它们在 Form.Designer.cs
文件 .
中的出现顺序相反
或者当按钮控件共享相同的控件时,它们总是优先于文本框控件tabindex
?
在某处记录了吗?
来自 MSDN Control.TabIndex Property
A tab index can consist of any valid integer greater than or equal to
zero, lower numbers being earlier in the tab order. If more than one
control on the same parent control has the same tab index, the z-order
of the controls determines the order to cycle through the controls.
还有一点细微差别:
For a control to be included in the tab order, its TabStop property
must be set to true.
因此,由于 z-index 值,您会看到具有相同 TabIndex
值选项卡的控件与代码隐藏文件的顺序相反。
当更多控件具有相同的 tabindex
属性 时,是什么决定了 Tab 键顺序?
例如,将文本框添加到空表单后,文本框的 tabindex
为 0。通过复制文本框(Ctrl + 鼠标拖动),新文本框也有 tabindex
0。然后我添加了一个按钮,它的 tabindex
是 1.
在 运行 程序之后,焦点在第二个文本框上。
然后我将按钮的 tabindex
更改为 0,因此之后所有控件都具有 tabindex
= 0,并且在 运行 程序之后焦点位于最后添加的按钮上。
这是否意味着在多个控件具有相同 tabindex
属性 的情况下,Tab 键顺序将与添加 控件的顺序相反 到表格?似乎共享相同 tabindex
的控件的 Tab 键顺序 与它们在 Form.Designer.cs
文件 .
或者当按钮控件共享相同的控件时,它们总是优先于文本框控件tabindex
?
在某处记录了吗?
来自 MSDN Control.TabIndex Property
A tab index can consist of any valid integer greater than or equal to zero, lower numbers being earlier in the tab order. If more than one control on the same parent control has the same tab index, the z-order of the controls determines the order to cycle through the controls.
还有一点细微差别:
For a control to be included in the tab order, its TabStop property must be set to true.
因此,由于 z-index 值,您会看到具有相同 TabIndex
值选项卡的控件与代码隐藏文件的顺序相反。