Reputation: 611
I want to create a tablelayoutpanel programmatically. I have code as follows:
TableLayoutPanel tlpCurrent = new TableLayoutPanel();
tlpCurrent.RowStyles.Clear();
tlpCurrent.RowCount++;
tlpCurrent.RowStyles.Add(new RowStyle(SizeType.Absolute, 40f));
tlpCurrent.RowCount++;
tlpCurrent.RowStyles.Add(new RowStyle(SizeType.Absolute, 40f));
tlpCurrent.RowCount++;
tlpCurrent.RowStyles.Add(new RowStyle(SizeType.Absolute, 40f));
tlpCurrent.RowCount++;
tlpCurrent.RowStyles.Add(new RowStyle(SizeType.Absolute, 40f));
tlpCurrent.RowCount++;
tlpCurrent.RowStyles.Add(new RowStyle(SizeType.Absolute, 40f));
tlpCurrent.RowCount++;
tlpCurrent.RowStyles.Add(new RowStyle(SizeType.Absolute, 40f));
tlpCurrent.RowCount++;
tlpCurrent.RowStyles.Add(new RowStyle(SizeType.Absolute, 40f));
tlpCurrent.RowCount++;
tlpCurrent.RowStyles.Add(new RowStyle(SizeType.Absolute, 40f));
tlpCurrent.ColumnStyles.Clear();
tlpCurrent.ColumnCount++;
tlpCurrent.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 150f));
for (int i = 0; i < 3; i++)
{
tlpCurrent.ColumnCount++;
tlpCurrent.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 150f));
}
tlpCurrent.Location = new Point(500, 100);
tlpCurrent.Size = new System.Drawing.Size(300, 300);
tlpCurrent.AutoSize = true;
this.Controls.Add(tlpCurrent);
But I cannot see it on windows form. I am sure this code runs without any error. Any ideas?
Upvotes: 2
Views: 1835
Reputation: 4408
To make the borders visible, you can use:
tlpCurrent.CellBorderStyle= TableLayoutPanelCellBorderStyle.Single;
Upvotes: 3