I have code that creates a PictureBox and I want it's background Image to change when I click it.
My code:
private void CreatImage()
{
Random LocationPicker = new Random();
for (int i = 0; i < 50; i++)
{
int X = LocationPicker.Next(0, 842);
int Y = LocationPicker.Next(245, 433);
PictureBox Image = new PictureBox();
Image.Name = "Image"; Image.BackgroundImage = Properties.Resources.Image24;
Image.BackColor = Color.Transparent;
Image.BackgroundImageLayout = ImageLayout.Stretch;
Image.Size = new Size(30, 30);
Image.Location = new Point(X, Y);
UpdateImage();
this.Controls.Add(Image);
}
}
private void UpdateImage()
{
//How do I change the Image I created above to have a diffrent BackgroundImage?
}