icon in statusbar panel

E

EricJ

Hi
I'm having trouble getting icons from an imagelist in a statusbar panel.
if i load the icons directly it works
Dim ico As new Icon("W95MBX03.ICO")

statusbarPanel..Icon = ico

but if i try to set the icon property with an imagelist i get this

Value of type 'System.Drawing.Image' cannot be converted to
'System.Drawing.Icon'

If anyone has a thought, pls let me know.

tnx in advance
 
J

Jonathan Williamson

When are you getting this error? At compile time? You may need to
explicitly cast the image you get an Icon object (if you have Option strict
on), or it may be that it is not an icon, but some other format of image.

Try doing something like this and see what you get;
Dim MyImage As Image
Dim MyIcon As Icon

MyImage = Me.ImageList1.Images(0)

If SrcOverlay.RawFormat.Equals(Drawing.Imaging.ImageFormat.Icon) Then
MyIcon = DirectCast(SrcOverlay, Drawing.Icon)

' Place icon into statusbar here

Else

MessageBox.Show("Not an Icon")

End If


BTW - not sure if this is the best way to check an image is actually an
icon, if there's a better way can someone shout?

Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top