如果您想将第一张卡片放在前面,您应该为卡片设置 2 个值,例如 cardGui1 和 cardGui2。第一个仅用于作为其他人完成循环的前列。
试试这个 :
const j =1;
cardGui2 = new cardGui2(j);
cardGui12.Location = new Point(10 + (j * 10), 10);
panel1.Controls.Add(cardGui2);
cardGui2.BringToFront();
for (int i = 1; i < 10; i++)
{
cardGui1 = new CardGui1(i);
cardGui1.Location = new Point(10 + (i * 10), 10);
panel1.Controls.Add(cardGui1);
}
更新 :
我假设最后一张卡片索引是 10。试试这个:
for (int i = 1; i < 10; i++)
{
cardGui1 = new CardGui1(i);
cardGui1.Location = new Point(10 + (i * 10), 10);
panel1.Controls.Add(cardGui1);
}
const j =10;
cardGui2 = new cardGui2(j);
cardGui12.Location = new Point(10 + (j * 10), 10);
panel1.Controls.Add(cardGui2);
cardGui2.BringToFront();