VB2005 Tips and Tricks – part 4

Use Strongly Typed Resources

  1. Double click My Project, Resources, select type images, and add an image. Change the resource name to MyImage
  2. Add a picture box or any other control that supports images and type: picturebox1.Image = My.Resources.MyImage

This will embed the image in your assembly. If you want to modify the image, replace the image inside the Resource Directory and recompile. There is no need to modify the code.

This approach is better than the ImageList because ImageList does not support typed resources. However, there are controls that do no support it and you have to fill the imagelist with the resource images in your code if you want to use it in this way.

Comments are closed.