Object reference not set to an instance of an object.
Error is given when trying to set Pic Location.
The goal of the above code is to create a control array of 32 by 32 picture boxes and place them on the form to create a 32x32 grid.
Error is given when trying to set Pic Location.
PictureBox[,] Pic = new PictureBox[31, 31];
public Form1()
{
InitializeComponent();
for (int X = 0; X < 32; X++)
{
for (int Y = 0; Y < 32; Y++)
{
Pic[X, Y].Location = new System.Drawing.Point(400 + (X * 32), 100 + (Y * 32));
Pic[X, Y].Size = new System.Drawing.Size(32,32);
}
}
}
The goal of the above code is to create a control array of 32 by 32 picture boxes and place them on the form to create a 32x32 grid.