I'm trying to create a custom panel containing some buttons and labels. The problem is that I can't set displaying order properly in code. I have something like this:
public partial class Pallete1 : Panel
{
private Label lblAutomatic;
private Label lbldivider1;
public Pallete1():base()
{
InitializeComponent();
this.lblAutomatic = new Label();
this.lbldivider1 = new Label();
this.lblAutomatic.Size = new Size(182,21);
this.lblAutomatic.Location = new Point(0, 0);
this.lblAutomatic.ForeColor = Color.FromArgb(0, 0, 64);
this.lblAutomatic.TextAlign = ContentAlignment.MiddleCenter;
this.lblAutomatic.Text = "Automatycznie";
this.lblAutomatic.Font = new Font("Microsoft Sans Serif", 8);
this.lbldivider1.Size = new Size(2,22);
this.lbldivider1.Location = new Point(26, 0);
this.lbldivider1.ForeColor = SystemColors.ControlText;
this.lbldivider1.BackColor = SystemColors.ButtonHighlight;
this.lbldivider1.BorderStyle = BorderStyle.Fixed3D;
this.Size = new Size(182, 184);
this.BackColor = SystemColors.ButtonHighlight;
this.BorderStyle = BorderStyle.FixedSingle;
this.Controls.AddRange(new Control[]{this.lblAutomatic,this.lbldivider1});
}
I would like lbldivider1
to be on the top of lblAutomatic
. When I add this item to some WinForm
projects, this second label is only seen when I drag my custom panel from one place to another. However it's not seen in the designer when it's not moving and also when I'm launching the application.
How can I fix it?