Reputation: 465
I have a picturebox that I want to load an image into at runtime depending on what a user types in a textbox.
I have created a file named Formations.resx within my project and loaded my images into it. I am have tried both of the following but had no luck, what am I doing wrong?
pictureBoxFormation.Image = Properties.Resources.ResourceManager.GetObject("random_" + firstPoint) as Image;
This code executes fine, but the .Image
property of my picturebox isn't updated by it, I am guessing that this code doesn't look in my file specifically, where is it looking?
ResourceManager rm = new ResourceManager("Formations", Assembly.GetExecutingAssembly());
pictureBoxFormation.Image = rm.GetObject("random_" + firstPoint) as Image;
This throws an error, which is as follows:
An unhandled exception of type 'System.Resources.MissingManifestResourceException' occurred in mscorlib.dll
Additional information: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Formations.resources" was correctly embedded or linked into assembly "WindowsFormsApplication1" at compile time, or that all the satellite assemblies required are loadable and fully signed.
Upvotes: 0
Views: 2677
Reputation: 465
Ended up moving the resources to Properties/Resources as suggested by Hans Passant, described in the comments to the original post.
Upvotes: 1