Q:

Detecting when error image in PictureBox is used

I found this on Google, click here, which someone asked a similar question, receiving a response that they should check if their file exists. However, I'm loading images from web links, in which it displays an error image if A)The picture is not found or B)If, like in image hosting services like Photobucket, displays the 'Bandwidth exceeded' image. Is there a way to detect if either an error image is showing or if a image is invalid?

A:

Yes, the LoadCompleted event tells you what went wrong:
private void pictureBox1_LoadCompleted(object sender, AsyncCompletedEventArgs e) {
  if (e.Error != null) {
    // You got the Error image, e.Error tells you why
  }
}

There could also be a case where the image load completed properly but there was something wrong with the image file itself:
private void pictureBox1_Paint(object sender, PaintEventArgs e) {
  if (pictureBox1.Image == pictureBox1.ErrorImage) {
    // You got the Error image
  }
}

This event handler catches load errors too so might be the one you want to use.

