I am trying to find out if the background image in a set of pictureboxes is the same as any of my image resources. The following always returns "None" for all the pictureboxes although they all have the background image player.
foreach (Control ctrl in this.radGroupBox1.Controls)
{
ctrl.BackgroundImage = Resources.player;
if ((Image)ctrl.BackgroundImage == (Image)Resources.blank)
Console.WriteLine("Blank");
else if ((Image)ctrl.BackgroundImage == (Image)Resources.player)
Console.WriteLine("Player");
else
Console.WriteLine("None");
}
Not sure why :(
Loading
Suthish NairPosted Mar 16, 2011, 3:21 PM
FroglegPosted Mar 14, 2011, 8:15 PM
pictureBox1.BackgroundImage = Properties.Resources.player;
pictureBox1.Tag = ("player");
if (pictureBox1.Tag == ("player"))
{
whatever
}
Sam HobbsPosted Mar 14, 2011, 8:03 PM
Jay WebsterPosted Mar 14, 2011, 7:41 PM
When I use: Console.WriteLine(ctrl.BackgroundImage.Equals((Image)Resources.player));
Console states False, the images are the same though....
Sam HobbsPosted Mar 14, 2011, 7:30 PM