コントロールを格子状に配置できます。

tableLayoutPanel1 = new TableLayoutPanel(); tableLayoutPanel1.ColumnCount = 2; tableLayoutPanel1.RowCount = 2; tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 50F)); tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 50F)); // コントロールの作成 label1 = new Label(); label2 = new Label(); label3 = new Label(); label4 = new Label(); // パネルへの配置 tableLayoutPanel1.Controls.Add(label1, 0, 0); tableLayoutPanel1.Controls.Add(label2, 1, 0); tableLayoutPanel1.Controls.Add(label3, 0, 1); tableLayoutPanel1.Controls.Add(label4, 1, 1);
| 型 | プロパティ | 内容 |
|---|---|---|
| int | ColumnCount | テーブル内の列の数 |
| int | RowCount | テーブル内の行の数 |
| メソッド | 機能 |
|---|---|
| SetColumnSpan(Control, Int32) | 子コントロールの列を、指定数だけつなげる |
| SetRowSpan(Control, Int32) | 子コントロールの行を、指定数だけつなげる |