468,296 Members | 1,266 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,296 developers. It's quick & easy.

icon in statusbar panel

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

--
Juchtmans Eric
Omnipack
Nov 20 '05 #1
3 1726
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.ImageF ormat.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

"EricJ" <er********@THISomnipack.be> wrote in message
news:3f***********************@reader0.news.skynet .be...
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

--
Juchtmans Eric
Omnipack

Nov 20 '05 #2
* "EricJ" <er********@THISomnipack.be> scripsit:
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'


<http://www.google.de/groups?selm=%23VfMRcmiDHA.2452%40tk2msftngp13.phx. gbl>

--
Herfried K. Wagner
MVP VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
do i have to declare SrcOverlay or do i need an import for that ?

"Jonathan Williamson" <jo*****************@amadeus.co.uk> wrote in message
news:Ob**************@TK2MSFTNGP11.phx.gbl...
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.ImageF ormat.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

"EricJ" <er********@THISomnipack.be> wrote in message
news:3f***********************@reader0.news.skynet .be...
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

--
Juchtmans Eric
Omnipack


Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Oleg Medyanik | last post: by
1 post views Thread by Ahmet | last post: by
10 posts views Thread by Nicolas | last post: by
7 posts views Thread by Geoff | last post: by
6 posts views Thread by Anony | last post: by
14 posts views Thread by Kishan Hathiwala | last post: by
10 posts views Thread by Flashster | last post: by
2 posts views Thread by reidarT | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by Teichintx | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.