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

Sam HobbsRank #107 · 20.5K reputationPosted Mar 14, 2011, 3:30 PM EDT
Jay Webster58 reputationPosted Mar 14, 2011, 3:41 PM EDT
When I use: Console.WriteLine(ctrl.BackgroundImage.Equals((Image)Resources.player));
Console states False, the images are the same though....
Sam HobbsRank #107 · 20.5K reputationPosted Mar 14, 2011, 4:03 PM EDT
FroglegRank #1,020 · 1.9K reputationPosted Mar 14, 2011, 4:15 PM EDT
pictureBox1.BackgroundImage = Properties.Resources.player;
pictureBox1.Tag = ("player");
if (pictureBox1.Tag == ("player"))
{
whatever
}
Suthish NairRank #92 · 22.8K reputationPosted Mar 16, 2011, 11:21 AM EDT