Color[] brickcolor = new Color[] { Color.Red, Color.Orange, Color.Pink, Color.Purple, Color.Blue, Color.Green, Color.Honeydew, Color.Lavender };
for (int c = 0; c <= 10; c++)
{
for (int r = 0; r <= 8; r++)
{
Label bricks = new Label();
bricks.Location = new Point(x, y);
bricks = brickcolor;
bricks.Width = 90;
bricks.Height = 25;
pnlGame.Controls.Add(bricks);
y += 30;
}
}
答案 0 :(得分:1)
for (int r = 0; r < 8; r++)
{
Label bricks = new Label();
bricks.Location = new Point(x, y);
bricks.BackColor = brickcolor[r]; //or bricks.ForeColor
bricks.Width = 90;
bricks.Height = 25;
pnlGame.Controls.Add(bricks);
y += 30;
}