Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ICON Image from ImageList Image 1

Status
Not open for further replies.

HRoarke

Programmer
Apr 27, 2004
64
US
Ok, here's one from the "Pretty Basic Questions" category:

VB.NET:

I have an ImageList with N images (of appropriate size, e.g. 16x16 or 32x32). I create an Icon variable, e.g.

Code:
private icoMyIcon as Icon

I want to assign an image from the ImageList to the new Icon using the ICON constructor, e.g.

Code:
icoMyIcon = New Icon ([various overloaded input params])

HOWEVER - the ICON constructor doesn't take an Image as an argument, and I can't find a way to get a DataStream (accepted by the overloaded ICON constructor) from the ImageList. There's gotta be a way.... a star to anyone that can point me in the right direction.

Thanks in advance

"I swear by my life and my love of it that I will never live for the sake of another man, nor ask another man to live for mine."
— John Galt
Atlas Shrugged

If you want to get the best response to a question, please check out FAQ222-2244 first

 
I ran into this same problem a while ago, here's my solution:

Code:
Dim ico As Icon = Icon.FromHandle(CType(ImageList.Images(0), Bitmap).GetHicon())

-Rick

----------------------
 
This works - thanks Rick! A star for you...

"I swear by my life and my love of it that I will never live for the sake of another man, nor ask another man to live for mine."
— John Galt
Atlas Shrugged

If you want to get the best response to a question, please check out FAQ222-2244 first

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top