C dynamically generates PictureBox and specifies the method of picture

  • 2021-07-09 09:02:21
  • OfStack

This article illustrates how C # dynamically generates PictureBox and specifies pictures. Share it for your reference. The details are as follows:


int Num = 0;
PictureBox[] pb;
Num = 6;
pb = new PictureBox[Num];
for (int i = 1; i < Num; i++)
{
  pb[i] = new System.Windows.Forms.PictureBox();
  pb[i].BorderStyle = BorderStyle.FixedSingle;
  pb[i].Location = new Point(50 + i * 110, 100);
  pb[i].SizeMode = PictureBoxSizeMode.Zoom;
  pb[i].Image = Image.FromFile(@"D:\pic\" + i + ".png");
  FlowPanel1.Controls.Add(pb[i]);
}

I hope this article is helpful to everyone's C # programming.


Related articles: