I need to add multiple panel into main panel, when I added second panel it will move on top the first added panel. please refer the image if you can't get what i means.
the question is, how can I add the following panel below the panel I just add?
public override DockStyle Dock { get; set; }
private void resultlabel()
{
Panel panel1 = new Panel();
panel1.Height = 50;
panel1.Dock = DockStyle.Top;
panel1.AutoSize = false;
panel1.AutoSizeMode = AutoSizeMode.GrowOnly;
panel1.AllowDrop = false;
panel1.CausesValidation = true;
if((totalitem % 2) == 0)
{
panel1.BackColor = Color.Blue;
}
else
{
panel1.BackColor = Color.Orange;
}
Label label1 = new Label();
label1.Text = count.ToString();
panel1.Controls.Add(label1);
mainPanel.Controls.Add(panel1);
count= count+ 1;
}