'Add panels dynamically to form

I'm trying to add panels to a form according to the ids quantity that is received. At running, the panels are added to the form, but only the first one has the controls, and I don't get why.

This is my actual code:

private void loadItems(List<int> ids)
{
    int id = 0,
        panelX = 10,
        panelY = -30,
        itemslblX = 15,
        itemslblY = -65,
        IDtxtX = 360,
        IDtxtY = -40,
        nametxtX = 130,
        nametxtY = -40;

    int height = (80 * ids.Count) + 50;
    this.Size = new Size(600,height);

    foreach(int c in ids)
    {
        panelY = panelY + 80;
        itemslblY = itemslblY + 80;
        terrainMenuY = terrainMenuY + 80;
        IDtxtY = IDtxtY + 80;
        nametxtY = nametxtY + 80;

        Panel panel = new Panel();
        panel.Location = new Point(panelX, panelY);
        panel.Dock = DockStyle.None;
        panel.Height = 75;
        panel.Width = 575;
        panel.BackColor = Color.Gray;
        panel.Name = ids[id]+"Panel".ToString();

        Label itemslbl = new Label();
        itemslbl.Location = new Point(itemslblX, itemslblY);
        itemslbl.Text = "Imagen            Nombre                                         ID";
        itemslbl.Height = 20;
        itemslbl.Width = 550;
        itemslbl.Name = ids[id] + "itemsLabel".ToString();

        TextBox IDtxt = new TextBox();
        IDtxt.Location = new Point(IDtxtX, IDtxtY);
        IDtxt.Height = 27;
        IDtxt.Width = 200;
        IDtxt.Text = ids[id].ToString();
        IDtxt.ReadOnly = true;
        IDtxt.Name = ids[id] + "IDtext".ToString();

        TextBox nametxt = new TextBox();
        nametxt.Location = new Point(nametxtX, nametxtY);
        nametxt.Height = 27;
        nametxt.Width = 200;
        nametxt.ReadOnly = true;
        nametxt.Name = ids[id] + "nameText".ToString();

        panel.Controls.Add(itemslbl);
        panel.Controls.Add(nametxt);
        panel.Controls.Add(IDtxt);

        this.Controls.Add(panel);
        id++;
    }
}

Here's how it seems

Any advice, please, and thanks for your time.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source