C# – Change icon’s format in C# Designer

ciconsnet

alt text http://i.imagehost.org/0734/Untitled_11.gif

How do I change the icon PictureBox shows?

The icon itself has multiple icons in it with different formats but for some reason the 16×16 is always used. How do I change that?

e.g. 32×32 , 48×48

Best Answer

Windows Forms has very poor support for icons. That starts with the Icon class itself, it has no way to enumerate the images in the icon or way to select which image is used in its ToBitmap() method. Fixing this got to be difficult with Vista, it expanded the icon file format to also support large images in the PNG format. Also not supported by Icon.

Punt this problem and convert the icon to a bitmap yourself. Visual Studio supports this, File + Open File, select your icon. Image + Current Icon Images Types, select the one you want to convert. Edit + Copy, that puts a bitmap of the icon on the clipboard. Paste into a new bitmap. Saving as a .png is best so that it can still support background transparency.