Icon from ImageList
-
I have an ImageList that I created using Icon (*.ico) files. I would like to extract an image as an Icon, but casting doesn't work: Icon test = (Icon)imgList.Images[1]; I know I can access the original .ico file from disk or resource, but since it was already loaded in an ImageList, I thought this would be an easier method. Does anyone know if this is possible? Thanks!
-
I have an ImageList that I created using Icon (*.ico) files. I would like to extract an image as an Icon, but casting doesn't work: Icon test = (Icon)imgList.Images[1]; I know I can access the original .ico file from disk or resource, but since it was already loaded in an ImageList, I thought this would be an easier method. Does anyone know if this is possible? Thanks!
-
the Bitmap class has a GetHicon() function. and the Icon class has an FromHandle(IntPtr) static function. so, maybe something like
Icon test = Icon.FromHandle(GetHicon(imgList.Images[1]));
does it? :wq
Thanks! Based on your suggestion, here's what worked: Icon test = Icon.FromHandle(new Bitmap(imgList.Images[1]).GetHicon()); Thanks again! Derek