By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,682 Members | 1,376 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,682 IT Pros & Developers. It's quick & easy.

icon in statusbar panel

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
* "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

P: n/a
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.