views:

2651

answers:

2

i Have some images in resources folder in my project but i want to change the picture box from these resource files of the project

+5  A: 

Consider using Properties.Resources.yourImage

Properties.Resources contains everything that you've added as a resource (see your project properties, resources tab)

Other than that, if you embed the images as resource in your project, you can get at them by calling GetManifestResourceStream on the assembly that you've embedded the images in, something like

Stream imgStream = 
    Assembly.GetExecutingAssembly().GetManifestResourceStream(
    "YourNamespace.resources.ImageName.bmp");
pictureBox.Image = new Bitmap(imgStream);

Don't forget to mark the image as an embedded resource! (You'll need to set the build action for the image in its properties window)

If you're finding that you keep getting back null from GetManifestResourceStream, you may be giving the wrong name. (It can be hard to get the names right) Call GetManifestResourceNames on the assembly; that will give you back all the resource names, and you can find the one in the list that you need.

Daniel LeCheminant
A: 

Describe your question more, please. Do you have your images embedded into a resource file which is a part of result assembly? And what do you want to do with it?

If you have just put some images to solution folder but didn't embedded them into a resource file, you need to that, so it result assembly will contains it, and you will able to use them into your code.

abatishchev
i have just put them in resources folder in the solution explorer and thats it Sorry but i don't know what you are talking about but i would love to learn it !!!
Mobin
Make a screenshot please
abatishchev