Changing an icon at runtime using an ImageList control
so, ever wanted to know just how to do this?
I found myself today pulling out what little hair I have left trying to do just this; eventually I found the solution but it was not obvious!
So being the nice person I am I decided to spare all you folk some hair and tell you how to do it, aint I nice?!?
Thinking this should be no problem at all I tried the following;
this.Icon = (Icon)imageList1.Images[0];
Unfortuantely my nice C# compiler decided that it could not
"Convert System.Drawing.Image to System.Drawing.Icon"
After much trauma, and many compile errors I eventually got this;
this.Icon = Icon.FromHandle(((Bitmap)imageList1.Images[0]).GetHicon());
Not exactly elegant or obvious ...
Anybody got a better way to do this?