当我单击button1时,我想将 面板之一,……添加到panel0中。
这是我的代码
private void button3_Click(object sender, EventArgs e)
{
int i = 0;
int j = 0;
Panel[] pnl = new Panel[3];
while ( i<2)
{
pnl[i].Parent = panel0; // erorr
pnl[i].BackColor = Color.PeachPuff;
pnl[i].Size = new Size(50, 10);
pnl[i].Location = new Point(j+5,10);
panel0.Controls.Add(pnl[i]);
pnl[i].BringToFront();
i++;
j = j + 13;
}
}
有建议吗?
答案 0 :(得分:0)
将Panel [] pnl =新Panel [3]更改为:
var pnl = new List<Panel>{existingPanel1, existingPanel2, existingPanel3};