Icon Stash

A

Alan Gillott

I'm converting a VB6 project to 2005. I stashed Icons in an Imagelist that I
used to change the icon of a Form (and System Tray) depending on
circumstance - I confess Red to Green and Viceversa - VB2005 won't let me do
this and I can't quite get my head around where I can stash my Icons. I
suspect the resource area but it doesn't offer me Icon as a format, and i
don't want to trial and error 8 or more times 'till I get it right.

Here's my bad code:
Me.Icon = ImageList1.Images.Item("Green")
Which errors out with:
Error 3 Value of type 'System.Drawing.Image' cannot be converted to
'System.Drawing.Icon'.

Please advise.
A
 
H

Herfried K. Wagner [MVP]

Alan Gillott said:
I'm converting a VB6 project to 2005. I stashed Icons in an Imagelist that
I used to change the icon of a Form (and System Tray) depending on
circumstance - I confess Red to Green and Viceversa - VB2005 won't let me
do this and I can't quite get my head around where I can stash my Icons. I
suspect the resource area but it doesn't offer me Icon as a format

"My Project" -> "Resources" supports icons. You can access the icon via
'My.Resources.*'.
 
A

Alan Gillott

Thank you.
The resource UI seems to differ from the way it is described in all the
books I have (does Express differ here?) and the UI I was looking at was
intuitivly unobvious.
Thanks
A
 
J

Just_a_fan

I just went through this one. Resourses IS the place to put the ICONs.
You just have to tell it what you are doing or you can just load in an
external file and it will probably decide what is right. I did it
manually and then a nice person here told me about "My.Resources" (since
I did not have a .NET 2008 book at that time).

Go to your project's resources screen. The drop-down on the left will
let you switch to ICON and you are off an running.

Then to change the form icon:

Me.Icon = My.Resources.Happy_Face


Mike
 

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