Pages

Monday, January 12, 2009

My.Resources in C# and Icons

To embed icons in a windows application, it is very easy to store them in the Resources. A new file can be added or a default one used. It can store strings, images, icons, etc. Once the icons are stored in the Resources.resx they can be accessed through

Properties.Resources

which is the equivalent of My.Resources from Visual Basic.net. The easiest way to use icons is to create and fill an ImageList, which is then utilized by TreeView or ListView.

            tvw.ImageList = new ImageList();
            tvw.ImageList.Images.Add("FolderIcon", Properties.Resources.FolderIcon);
            tvw.ImageList.Images.Add("ItemIcon", Properties.Resources.ItemIcon);


1 comment:

infoelect said...

This is widely used in international applications, you only need to create a resource file with the extention of the language for example resource.es.resx