I have 1 picturebox loaded with an image, what i'm trying to do is every time i click on loaded image the same picture loads into empty picturebox. Now for 1 picturebox is easy, all i do is picturebox1.Image = img;
I'm trying to make an event that will load image to next empty picture box
This code is in the picturebox.click event that is loaded with image
int counter = 0;
List<PictureBox> pbox= new List<PictureBox>(); //Holds list of PictureBoxes that will be loaded(currently there are 28)
PictureBox img = ((PictureBox) sender); //Holds the image that i clicked
foreach (Control ctrl in groupBox1.Controls) //Enumerate all controls and add them to the list
{
if (ctrl is PictureBox)
{
pbox.Add((PictureBox) ctrl);
}
}
pbox[counter] = img; //loads the image to the first picturebox in list
pictureBox1.Image = pbox[counter].Image; // Now this should load the image (i need help with this), what should i use instead picturebox1.Image
counter++;