tags:

views:

164

answers:

1

alt text

How do I change the icon PictureBox shows?

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

e.g. 32x32 , 48x48

+1  A: 

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.

Hans Passant