hi I'm trying to create a list that contains my customised Panel called MyPanel, and add the panels in the list to my from. however it seems like when Form1 load, the form is actually showing 1 panel instead of 10 panels in total. here is my code:
private void Form1_Load(object sender, EventArgs e)
{
List<MyPanel> tenPanels = new List<MyPanel>();
for(int i=0;i<10;i++)
{
MyPanel mp = new MyPanel();
tenPanels.Add(mp);
mp.Name = "digitPanel" + i;
mp.Location = new System.Drawing.Point(10+i, 32);
mp.Size = new System.Drawing.Size(147, 173);
this.Controls.Add(mp);
}
foreach(Panel p in tenPanels)
{
this.Controls.Add(p);
}
}
Form1_Load is visual studio automatically generated event
Aucun commentaire:
Enregistrer un commentaire