Using images from resources

LeonR

Well-known member
Joined
Nov 2, 2006
Messages
139
Location
UK
Programming Experience
10+
This is probably quite simple, but it keeps tripping me up.

I have added a .png to my project (in solution explorer).
Now all I need to do is simply point a picturebox at this resource and display it.

I'm obviously missing something quite primitive! I assume that would be classed as a 'resource' ? I don't want to load images from file paths, it just makes it messy for the user + they could technically change what is displayed within the program.

Thanks,
Leon
 
You should add the image to project resources, they are in project properties in Resources tab. You can copy the image file in filesystem (Explorer) and paste into this window, or use the 'add resource' > 'add existing file' and browse to it.
Then in designer you can select the Image property of the PictureBox and select the image resource. In code this resource may be accessed through the My.Resources object.
 
Back
Top