Search code examples
c#.netpicturebox

Open image from PictureBox in windows photo viewer using ImageLocation


I am trying to open an image from the PictureBox using ImageLocaton Property, because I want in the future to store the images on an online Database.

I've tried this code but says that pictureBox1.ImageLocation.ToString() is null:

private void pictureBox1_Click(object sender, EventArgs e)
{
    Process.Start(pictureBox1.ImageLocation.ToString());
} 

I also have seen it in the properties tab, but why?

I also have seen it in the properties tab, but why?


Solution

  • You just need to set the ImageLocation of the pictureBox to set its Image (not get it that is obviously null if not set):

    pictureBox1.ImageLocation = someurl;