SoFunction
Updated on 2025-03-08

C# dynamically generates PictureBox and specifies the method

This article describes the method of dynamically generating PictureBox and specifying pictures in C#. 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 ();
  pb[i].BorderStyle = ;
  pb[i].Location = new Point(50 + i * 110, 100);
  pb[i].SizeMode = ;
  pb[i].Image = (@"D:\pic\" + i + ".png");
  (pb[i]);
}

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