我正在尝试使用winform
复制此excel表:
// TableLayoutPanel Initialization
TableLayoutPanel panel = new TableLayoutPanel();
panel.ColumnCount = 14;
panel.RowCount = 2;
panel.Controls.Add(new Textbox() { Text = "Address" }, 1, 0);
panel.Controls.Add(new Textbox() { Text = "Contact No" }, 2, 0);
panel.Controls.Add(new Textbox() { Text = "Email ID" }, 3, 0);
在Windows窗体中,我可以通过执行以下操作来动态添加控件:
for (int i = 0; i < 5; i++)
{
Button button = new Button();
button.Location = new Point(160, 30 * i + 10);
button.Tag = i;
this.Controls.Add(button);
}
如何在TableLayoutPanel
中动态添加控件,同时保留所有textbox
控件并遍历每条记录?