嗯,首先你应该创建一个结构:
public struct Block
{
public string Name { get; set; }
public int Rows { get; set; }
public int Seats { get; set; }
}
第二次将数据填充为列表:
List<Block> blocks = new List<Block>
{
new Block { Name = "A", Rows = 10, Seats = 15 },
new Block { Name = "B", Rows = 6, Seats = 10 },
new Block { Name = "C", Rows = 6, Seats = 10 },
new Block { Name = "D", Rows = 10, Seats = 15 },
new Block { Name = "E", Rows = 8, Seats = 25 },
new Block { Name = "F", Rows = 8, Seats = 25 },
};
并绘制或创建表单控件,例如廉价标签:
int selectedIndex = 3;
Block block = blocks[selectedIndex];
this.Text = "Block: " + block.Name; // Window Title = "Block: D"
for (int y = 0; y < block.Rows; y++)
{
for (int x = 0; x < block.Seats; x++)
{
Label label = new Label();
label.Left = x * 50;
label.Top = y * 20;
label.Width = 50;
label.Height = 20;
label.Text = "[" + (y + 1) + ", " + (x + 1) + "]";
this.Controls.Add(label);
}
}
要获得更好的答案,请提出更精确的问题;-)