Im making few buttons(picturebox) that then you click them they change image.
I tryed this code but it always skips to else.
Images are loaded from resources.
private void pictureBox7_Click(object sender, EventArgs e)
{
if (pictureBox7.Image == KaminuSkaiciuokle.Properties.Resources.IcopalA)
{
pictureBox7.Image = KaminuSkaiciuokle.Properties.Resources.IcopalB;
}
else
{
pictureBox7.Image = KaminuSkaiciuokle.Properties.Resources.IcopalA;
}
}
Figured that out.
Insted comparing picturebox.image I set picturebox.tag and compare.
pictureBox7.Tag = "B";
if (pictureBox7.Tag.ToString() == "A")
{
pictureBox7.Image = KaminuSkaiciuokle.Properties.Resources.IcopalB;
pictureBox7.Tag = "B";
}
else
{
pictureBox7.Image = KaminuSkaiciuokle.Properties.Resources.IcopalA;
pictureBox7.Tag = "A";
}
You should keep local reference to your resources, because when you invoke
KaminuSkaiciuokle.Properties.Resources...
you will always get new instance of object:please attention this code:
_icopalABitmap:it is name you ideal that. KaminuSkaiciuokle: it aqual your project name. IcopalA: is your picture name