Search code examples
c#imagepicturebox

How to Make PicBox to form?


I want to create a program that will create the picturebox to the number that the user enters.

I use the following code.

        int i,j,X = 395, Y = 7, S = 200 / int.Parse(textBox2.Text), C = int.Parse(textBox2.Text),CCC = 0;
        PPP = new PictureBox[C];
        for (i = 0; i < C; i++)
        {
            X = X + 5;
            for (j = 0; j < C; j++)
            {
                Y = Y + 5;
                PPP[CCC] = new PictureBox()
                {
                    BackColor = Color.OrangeRed,
                    Size = new Size(S, S),
                    Location = new Point(X, Y)
                };
                Controls.Add(PPP[CCC]);
            }
            CCC++;
        }

Thanks.


Solution

  • Part of the problem is that you have to update X and Y so your PictureBoxes are not drawn on top of each other.