As part of the Visual Basic project, I added a resource file (resx) containing a bunch of images.
Now I want to request image names. If I open the resx file in the designer view in the Visual Studio IDE and select the image, the property grid will show me the name property (the default is “file name without extension, but can be changed”).
The background is that I have a mutist that is created at runtime and populated with images from the resource file. To access these images using a key, I have to install it.
My code looks like this (everything is hardcoded):
Dim imagelist as new Imagelist imageList.Images.Add("A", My.Resources.MyImages.A) imageList.Images.Add("B", My.Resources.MyImages.B) imageList.Images.Add("C", My.Resources.MyImages.C) imageList.Images.Add("D", My.Resources.MyImages.D) imageList.Images.Add("E", My.Resources.MyImages.E) .... imageList.Images.Add("XYZ", My.Resources.MyImages.XYZ)
And I want to achieve this:
Dim imagelist as new ImageList For Each img in GetMeAllImagesWithNameFromMyResourceFile imageList.Images.Add(img.Name, img.ImageFile) Next
where Name is a string and ImageFile is System.Drawing.Bitmap
source share