I've got a question about Icons, i've loaded a few icons into an image list and when I try assign an image to the forms icon property I'm getting a type exception because the imagelist contains 'images', lol.
This being the case, how do I convert an 'image' from my imagelist to an icon that the form will accept By the way, this is also true for the NotifyIcon control, that will only accept icons too.
Its ironic that they were all icons to begin with.

Icons from Imagelists?
GregRoberts
The method doesn't work, the compiler is telling me that GetHicon is not a member of system.drawing.image.
It wouldnt take the 'bitmap' bit either. I had to modify it to this:
Intray.Icon = Icon.FromHandle((IC.Images(
"RANK1")).GetHicon())Intray is my NotifyIcon control and IC is my imagelist.
Raymond Mak
You pointed me in the right direction.
Imports
System.DrawingPublic Function CVIcon(ByVal cBitmap As Bitmap) As Icon
Dim HIcon As IntPtr = cBitmap.GetHicon()
CVIcon = System.Drawing.Icon.FromHandle(HIcon)
End Function
Works like a charm. Just drop that in a module.
Mukhtar Omar
Hey Psych,
Put your email address in your profile.
Mister Ken
dragonroll
I dont really want to put my email address in here, lol.
psych_uk at hotmail.com
elliotg2005
Given that the images within the ImageList are really being stored as Bitmaps we can typecast them to another type whose handle we can get and use for the construction of a new icon ala:
this.Icon = Icon.FromHandle(((Bitmap)imageList1.Images[0]).GetHicon());
I do need to give credit to Ryan Farley for this method.