I'm trying to accomplish something like this:
label1_Click(object sender, eventargs e){
int number = 1;
string labelName = "label" + number;
Control area = this.Controls.Find(labelName, true)[0];
if (area.BackgroundImage == Properties.Resources.image1){
area.BackgroundImage = Properties.Resources.image2;
...
}
else {
area.BackgroundImage = Properties.Resources.image3;
}
}
I can't get my If statement to fire (It passes straight over it without saying there is an error in the code when trying to compare in my if statement). What is the best way to detect a label's background image? It's for a small game which requires a lot of image changes. I am flexible if Labels are a horrible way to do this but that's just how I started. The main goal is to dynamically detect a background image and change it to a different image depending on what the original image is and where the user clicks.
Aucun commentaire:
Enregistrer un commentaire