简体   繁体   中英

Resources in Visual Studio 2013

I am trying to add a myimage.jpg as a resource in Visual Studio 2013 for a C# project. I need to dynamically load these resources. I added the myimage.jpg to the resources of the project and set it as a embedded resource. Then in my code I try to use the resource by using

pictureBox1.Image = WindowsFormsApplication1.Properties.Resources.myimage

but the choices I have after Resources. are culture, equals, reference equals and resource manager. Why is myimage not a choice?

This works correctly for me. I added a JPG image to the resources tab in project properties, then loaded the image into a picturebox with the following code:

pictureBox1.Image = Properties.Resources._17080

The image appeared in the picturebox as expected.

This also works when I specifically reference the form:

WindowsFormsApplication1.Properties.Resources._17080

If you are instead creating a custom resources file (Resource1.resx), then you can use this:

pictureBox1.Image = Resource1._17808

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM