Search code examples
c#picturebox

Displaying an image that is stored in the solution c#


I want to display an image in a picture box which I have saved in my solution folder.

enter image description here

Is there an easy way for this to be done? I have seen examples of loading from resources using streams etc. But that seems far too much code for what I'm trying to do.

    if (ds.Tables[0].Rows[0]["GDPRState"].ToString() == "1")
    {
         picture_GDPR.Image = Image.FromFile("");
    }

Do I want to be using the FromFile function to achieve this?


Solution

  • https://www.youtube.com/watch?v=LQMDsJgMXhE

    The above YouTube video helped explain it to me.

    I had just copied my image into the directory and not added it as a resource. When I had added it correctly the following code worked.

    picture_GDPR.Image = Properties.Resources.gdpr_test;