Winform代码、设计器添加控件 顶层底层位置不同
设计器里添加时先加的控件在底层,后拖拽过去的控件覆盖在之前控件上(在顶层);
代码添加时,先加的控件在顶层,后加的反而在底层,为什么?
private void Form1_Load(object sender, EventArgs e)
{
TextBox pa1 = new TextBox();
pa1.Location = new Point(110, 110);
pa1.Size = new Size(30, 30);
pa1.BackColor = Color.Black;
this.Controls.Add(pa1);
Panel pa = new Panel();
pa.Location = new Point(100, 100);
pa.Size = new Size(100, 100);
pa.BackColor = Color.White;
this.Controls.Add(pa);
}
private void Form1_Load(object sender, EventArgs e)
{
Panel pa = new Panel();
pa.Location = new Point(100, 100);
pa.Size = new Size(100, 100);
pa.BackColor = Color.White;
this.Controls.Add(pa);
TextBox pa1 = new TextBox();
pa1.Location = new Point(110, 110);
pa1.Size = new Size(30, 30);
pa1.BackColor = Color.Black;
this.Controls.Add(pa1);
}