I have a string array \"abc\" I put this in a for each loop. I want to retrieve an image from resources using the value in the foreach loop and put it into a picture box.
Here is a simple method you can use
Add to your code and replace XXXAPPNAMEXXX with the name of you application.
public Bitmap GetImageResourceByName(string name)
{
Bitmap MethodResult = null;
try
{
MethodResult = (Bitmap)XXXAPPNAMEXXX.Properties.Resources.ResourceManager.GetObject(name, XXXAPPNAMEXXX.Properties.Resources.resourceCulture);
}
catch //(Exception ex)
{
//ex.HandleException();
}
return MethodResult;
}
Note: Go into Resources.Designer.cs and make the private attribute resourceCulture public.
I have commented out my error handling (ex.HandleException) as yours may differ.