I'm trying to position my label "date" over my other labels. But i'm really struggling with it. I tried it with bringToFront and with sendToBack, but neither worked. My goal is, that the date label is at the front.
Code:
//Create Fill Panels
createFillPanels();
//Create Panel
Panel test = new Panel();
count++;
//Fill Panel
test.Name = "panel" + i;
test.Width = 245;
test.Height = 170;
test.BackColor = Color.White;
Label date = new Label();
if(i >= 9)
{
int description = i + 1;
date.Text = description.ToString();
}
else
{
int description = i + 1;
date.Text = 0 + description.ToString();
}
//Create Label
string day = date.Text;
string year = DateTime.Now.Year.ToString();
string month = tbMonat.Text;
string stringDate = day + "." + month + "." + year;
DateTime dt = Convert.ToDateTime(stringDate);
if (dt.DayOfWeek == DayOfWeek.Sunday)
{
test.BackColor = Color.LightGray;
}
//Label frühschicht
Label frühschicht = new Label();
string frühschichtText = datenbank.panelBefüllen(tag, monat, jahr, "Frühschicht", null, null, null, null);
if(frühschichtText != null)
{
frühschicht.Text = "Frühschicht: " + frühschichtText;
frühschicht.ForeColor = Color.Black;
frühschicht.Width = 215; }
frühschicht.Location = new System.Drawing.Point(frühschichtlocationX, frühschichtlocationY);
date.Location = new System.Drawing.Point(datelocationX, datelocationY);
foreach (Control c in this.Controls)
if (frühschicht.Text.Contains("Offe"))
{
frühschicht.BackColor = Color.LightPink;
fehlercount++;
}
frühschicht.SendToBack();
test.Controls.Add(frühschicht);
date.BringToFront();
test.Controls.Add(date);
flowLayoutPanel1.Controls.Add(test);
test.Show();
//Label spätschicht
Label spätschicht = new Label();
string spätschichtText = datenbank.panelBefüllen(tag, monat, jahr, "Spätschicht", null, null, null, null);
if (spätschichtText != null)
{
spätschicht.Text = "Spätschicht: " + spätschichtText;
spätschicht.ForeColor = Color.Black;
spätschicht.Width = 215;
}
spätschicht.Location = new System.Drawing.Point(spätschichtlocationX, spätschichtlocationY);
spätschicht.SendToBack();
test.Controls.Add(spätschicht);
date.Location = new System.Drawing.Point(datelocationX, datelocationY);
date.BringToFront();
foreach(Control c in this.Controls)
if(spätschicht.Text.Contains("Offe"))
{
spätschicht.BackColor = Color.LightPink;
fehlercount++;
}
test.Controls.Add(date);
flowLayoutPanel1.Controls.Add(test);
test.Show();
Picture: How it looks like at the moment