I have a quick question, I have been struggling with something that should, in theory be quite simple.
I want to create a dynamic button out of a picture box in Visual Studio 2012, one that changes the image each time I click it.
if (pictureBox4.BackgroundImage == MyProject.Properties.Resources._1)
pictureBox4.BackgroundImage = MyProject.Properties.Resources._2;
else if (pictureBox4.BackgroundImage == MyProject.Properties.Resources._2)
pictureBox4.BackgroundImage = MyProject.Properties.Resources._1;
Now, this didn't really work fine. It wouldn't detect the image that is being currently displayed and enter the if
statement. So, instead, I've tested it this way.
int b = 1;
if (b == 1)
{
pictureBox4.BackgroundImage = MyProject.Properties.Resources._2;
b = 2;
}
if (b == 2)
{
pictureBox4.BackgroundImage = MyProject.Properties.Resources._1;
b = 1;
}
Close... but no cigar. When I click it the image does change, but just once; if I click it again, it stays the same...
So... what now? Thanks for your answers.