// Create TableLayoutPanel
TableLayoutPanel tlp = new TableLayoutPanel();
// Set the BorderStyle to Inset
tlp.CellBorderStyle = TableLayoutPanelCellBorderStyle.Inset;
// Grid has two columns
tlp.ColumnCount = 2;
// Grid has two rows
tlp.RowCount = 2;
// If grid is full add extra cells by adding column
tlp.GrowStyle = TableLayoutPanelGrowStyle.AddColumns;
// Padding (pixels)within each cell (left, top, right, bottom)
tlp.Padding = new Padding(1, 1, 4, 5);
// Add TableLayoutPanel to the Forms controls
this.Controls.Add(tlp);
/
// Create buttons
Button button1 = new Button();
button1.Text = "Click Me";
// Resize the TableLayoutPanel
tlp.AutoSize = true;
// Add buttons to TableLayoutPanel
tlp.Controls.Add(button1);
// Add buttons to TableLayoutPanel
tlp.Controls.Add(button1, 1, 0);
public virtual void Add(
Control control,
int column,
int row
)
//
tableLayoutPanel1.ColumnStyles[0].SizeType = SizeType.Absolute;
tableLayoutPanel1.ColumnStyles[0].Width = 20;
tableLayoutPanel1.RowStyles[0].SizeType = SizeType.Percent;
tableLayoutPanel1.RowStyles[0].Height = 50;
/
// merge cell
tlp.SetColumnSpan(button1, 2);
//or
tlp.SetRowSpan(button1, 2);
// from: ---- http://en.csharp-online.net/TableLayoutPanel