Is Picturebox a certain image

  • Thread starter Thread starter Andy
  • Start date Start date
A

Andy

I am building an application to automate some testing. The status of
each of the tests is depicted by an image. This can either be an hour
glass, a cross or a tick and is initially set like so...

pictureBox1Status.Image =
global::TestApp.Properties.Resources.sandglass_48

If the test passes its image is changed to a tick using the same
method. All fairly simple.

When a timer expired I wanted to see which tests were still awaiting
results. The easiest way was to see if the image was still an hour
glass (instead of a separate status bool). I tried ...

if (pictureBox1Status.Image ==
global::TestApp.Properties.Resources.sandglass_48)
{
// change image to cross
}

Yep, the above test doesn't work. Its probably something simple and
silly but for the life of me I can't see what. I've tried all sorts,
like casting the image to a bitmap.

Could someone point out where my thinking is going wrong please.

Thanks in advance.

Andy
 
if (pictureBox1Status.Image ==
global::TestApp.Properties.Resources.sandglass_48)
{
// change image to cross
}

Yep, the above test doesn't work. Its probably something simple and
silly but for the life of me I can't see what. I've tried all sorts,
like casting the image to a bitmap.

Could someone point out where my thinking is going wrong please.

The Image in the Picture Box is the image in the Picture Box, so can't be
tested for equality with one of your resources - unless you want to write
a function to compare it pixel by pixel :-)

Are you using the Tag on the Picture Box for anything? If not you could
set it to a number to represent the status.
 
The Image in the Picture Box is the image in the Picture Box, so can't be
tested for equality with one of your resources - unless you want to write
a function to compare it pixel by pixel :-)

Are you using the Tag on the Picture Box for anything? If not you could
set it to a number to represent the status.

Jeff,

Thanks for the quick reply.

I just had it in my head that being a local resource it would see if
it is the same object that was loaded, if you see what I mean.

I am actually using the tag in a similar manner as you suggested to
get over my problem. I just wanted to understand why the other
mechanism wasn't working as it seemed simpler.

Cheers

Andy
 
Back
Top