TableLayoutPanel: Table layout Panel, suitable for dynamically adding (display) controls in tabular form. Overview of Usage: Drag-and-drop TableLayoutPanel to the specified area of the form-generally make basic settings or add rows or columns, others need to write code to control the display//<summary>
Drawing controls
</summary>
private void Paintcontrol ()
{
Delete the default row and column styles
TableLayoutPanel1.ColumnStyles.Clear ();
TableLayoutPanel1.RowStyles.Clear ();
This.tableLayoutPanel1.Controls.Clear ();
this.tableLayoutPanel1.ColumnCount = 4;
Label lb = null;
if (tableitems! = null && tableitems. Rows.Count > 0)
{
This.tableLayoutPanel1.RowCount = ( Tableitems. Rows.Count% 2 = = 0? Tableitems. ROWS.COUNT/2: Tableitems. ROWS.COUNT/2 + 1);
this.tableLayoutPanel1.Height = * THIS.TABLELAYOUTPANEL1.ROWCOUNT;
this. Height = This.tableLayoutPanel1.Height;
for (int RowIndex = 0; RowIndex < Tableitems. Rows.Count; rowindex++)
{
LB = new Label ();
Lb. Text = Tableitems. rows[rowindex]["Itemtext"]. ToString ();
Lb. Parent = TableLayoutPanel1;
THIS.TABLELAYOUTPANEL1.CONTROLS.ADD (LB, rowindex%2*2, ROWINDEX/2);
TextBox text = new TextBox ();
Text. Name = "txt" + tableitems. rows[rowindex]["Itemvalue"]. ToString ();
Text. Width = 148;
Text. Parent = TableLayoutPanel1;
THIS.TABLELAYOUTPANEL1.CONTROLS.ADD (text, rowindex%2*2+1, ROWINDEX/2);
}
}
}