Setting the ImageSize property prior to adding images to the image collection causes the images to be resized to the image size specified.
When you set the ImageSize property to a new value, the Handle for the image list is recreated.
Because setting the ImageSize property causes the handle to be recreated, you should set ImageSize prior to setting the Images property. When the handle for the ImageList has been created, setting the ColorDepth or ImageSize properties in code, after setting the Images property, will cause the collection of images set for the Images property to be deleted.
The following code example demonstrates constructing an ImageList, adding images to the Images property, setting the ImageSize property, and using the Draw method. To run this example, place it in a form containing a button named Button1. The example assumes the existence of FeatherTexture.bmp and Gone Fishing.bmp at c:\Windows\. Change the example accordingly if the bitmaps do not exist on your system, or exist at another location.
setting the ImageSize property and the use of the Draw method.
To run this sample place it in a form containing a button named Button1.
The sample assumes the existence of FeatherTexture.bmp and
Gone Fishing.bmp at c:\Windows\. Change the sample accordingly if the
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)