-1

I am trying to load an image to picture box the below way worked with me.

image1.Image = Properties.Resources._0;

what it i want make the code reading from resources as variable name like the way below.

var imagename = _0;

image1.Image = Properties.Resources.imagename;

Thanks

Rai Vu
  • 1,595
  • 1
  • 20
  • 30

1 Answers1

0

Use the ResourceManager and pass it a string:

var imageName = "_0";
image1.Image = (Image)Properties.Resources.ResourceManager.GetObject(imageName);
Jcl
  • 27,696
  • 5
  • 61
  • 92