I need to check if the button have no image(BackColor changes to green) or an image called Atorre(BackColor changes to red), heres my code:
public static bool IsEnemyOrEmptyA(Button check)
{
var Atorre = teste.Properties.Resources.Atorre;
bool res;
if (check == null || check.Image == null)
{
res = true;
check.BackColor = Color.Green;
return res;
}
else if (check.Image == teste.Properties.Resources.Atorre)
{
res = true;
check.BackColor = Color.Red;
return res;
}
else
{
res = false;
return res;
}
}
but even if its an other image, the button displays backcolor red or nothing. Any suggestions?
Pravesh Singh
04-Feb-2014This is the only way to compare images, you shouldn't be comparing images but instead compare some variables.