Tom Knowlton
asked on
Array of PictureBox controls
In my form I create a 10 x 10 array of PictureBox controls, like this:
public System.Windows.Forms.Pictu reBox[,] pBoxArray = new System.Windows.Forms.Pictu reBox[10,1 0];
Then later I want to SHOW the images assigned to the PictureBox controls using a nest for loop.
How do I assign each picture box in the array to the Parent Form and make the image show up?
public System.Windows.Forms.Pictu
Then later I want to SHOW the images assigned to the PictureBox controls using a nest for loop.
How do I assign each picture box in the array to the Parent Form and make the image show up?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
try
pBoxArray[i,j].Location=ne w Point(i*20,j*20);
pBoxArray[i,j].Size=new Size(20,20);
pBoxArray[i,j].Location=ne
pBoxArray[i,j].Size=new Size(20,20);
ASKER
Der...I forgot to set LOCATION of the pBoxArray items.
:-) beat you to it.
ASKER
My current solution (until I tweak it again) L)
public void InitPictureBoxArray()
{
for(int i=0;i<10;i++)
{
for(int j=0;j<10;j++)
{
pBoxArray[i,j] = new System.Windows.Forms.Pictu reBox();
pBoxArray[i,j].Image = gw.gamePieceArray[i,j].pic _box.Image ;
pBoxArray[i,j].Location=ne w Point(i*32,j*32);
pBoxArray[i,j].Size=new Size(32,32);
this.Controls.Add(pBoxArra y[i,j]);
}
}
}
public void InitPictureBoxArray()
{
for(int i=0;i<10;i++)
{
for(int j=0;j<10;j++)
{
pBoxArray[i,j] = new System.Windows.Forms.Pictu
pBoxArray[i,j].Image = gw.gamePieceArray[i,j].pic
pBoxArray[i,j].Location=ne
pBoxArray[i,j].Size=new Size(32,32);
this.Controls.Add(pBoxArra
}
}
}
ASKER
That you did.
I have a related question....I'll ask it in just a minute.
I have a related question....I'll ask it in just a minute.
ASKER
ASKER
Okay....we are on the right track.
Now I don't understand why only the first image [0,0] is showing:
public void InitPictureBoxArray()
{
for(int i=0;i<10;i++)
{
for(int j=0;j<10;j++)
{
pBoxArray[i,j] = new System.Windows.Forms.Pictu
pBoxArray[i,j].Image = gw.gamePieceArray[i,j].pic
this.Controls.Add(pBoxArra
}
}
}