private void CheckP_Load(object sender, EventArgs e) { int mc; UpdateDBLin ul = new UpdateDBLin(); mc = ul.getPreCount(ui.UName); List <int> li = ul.getPredID(ui.UName); if (mc == 0) { label3.Visible = true; } Panel[] x = new Panel[mc]; int range = 3; for (int i = 0; i < mc; i++) { x[i] = new Panel(); x[i].Name = "Panel" + i; x[i].Size = new Size(313, 87); x[i].Location = new Point(3, range); range += 93; x[i].Visible = true; x[i].BackgroundImage = Image.FromFile(@"F:\Important Documents\Project\dota.jpg"); x[i].BackgroundImageLayout = ImageLayout.Stretch; panel1.Controls.Add(x[i]); Label[] l = new Label[2]; PictureBox[] p = new PictureBox[3]; Button b = new Button(); b.Text = "Results"; b.Location = new Point(119, 59); b.Visible = true; b.Size = new Size(75, 23); b.Click += new EventHandler(button_Click); b.Name = li.ElementAt(i).ToString(); x[i].Controls.Add(b); string[] t = ul.getPredTeam(li.ElementAt(i)); for (int j = 0; j <= 1; j++) { l[j] = new Label(); l[j].Visible = true; l[j].Name = "Label" + j; l[j].Size = new Size(60, 40); l[j].Text = t[j]; l[j].TextAlign = ContentAlignment.MiddleCenter; x[i].Controls.Add(l[j]); p[j] = new PictureBox(); p[j].Visible = true; p[j].BackgroundImage = Image.FromFile(@ul.getIconPath(t[j])); p[j].BackgroundImageLayout = ImageLayout.Zoom; p[j].Size = new Size(45, 42); x[i].Controls.Add(p[j]); } l[0].Location = new Point(53, 11); l[1].Location = new Point(190, 11); p[0].Location = new Point(3, 11); p[1].Location = new Point(265, 11); p[2] = new PictureBox(); p[2].Size = new Size(45, 42); p[2].Visible = true; p[2].Location = new Point(128, 11); p[2].BackgroundImage = Image.FromFile(@"F:\Important Documents\Project\Vs2.png"); p[2].BackgroundImageLayout = ImageLayout.Zoom; x[i].Controls.Add(p[2]); } }