[英]TableLayoutPanel: How can i navigate with tab key through dynamically added controls?
I have a form which contains a dynamically added TableLayoutPanel, which contains some dynamically added Labels, TextBox, CheckBox.我有一个包含动态添加的 TableLayoutPanel 的表单,其中包含一些动态添加的标签、文本框、复选框。 I am obtaining exactly the visualization I would like to have, but I am struggling to get the "tab key" to work for moving from one control to the other.
我正在获得我想要的可视化效果,但我正在努力使“tab 键”能够从一个控件移动到另一个控件。 I have tried to add a:
我试图添加一个:
control.TabIndex = tabIndex++;
control.TabStop = true;
But this doesn't seem to have any impact...但这似乎没有任何影响......
This is the (tested) stub code:这是(经过测试的)存根代码:
class MyForm : Form
{
public MyForm()
{
InitializeComponent();
string[] titles = {"first","second"};
var myLayout = new TableLayoutPanel();
myLayout.AutoSize = true;
int myTabIndex = 1; //Not really necessary
int rowNumber = 0;
foreach (var title in titles)
{
var label = new Label();
label.Text = title;
myLayout.Controls.Add(label, 0, rowNumber);
var control = new TextBox();
control.TabIndex = myTabIndex++; //Not really necessary
myLayout.Controls.Add(control, 1, rowNumber);
rowNumber++;
}
this.Controls.Add(myLayout);
}
}
This is the window I get, and I am not able to navigate from first to second field using the tab key.这是我得到的窗口,我无法使用 Tab 键从第一个字段导航到第二个字段。
Update:更新:
Applying Visual Studio 2013 Update 5 did not help.应用Visual Studio 2013 Update 5没有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.