newbie icon question

S

SStory

OK... Just don't get it yet....

I have a form and want to use 1 of 2 different icons depending on how it is
called.

If I put my icons in an imagelist, they become bitmaps and can't set the
form

me.icon= to them

seems to be no way to convert from bitmap to icon and can't figure out how
to just store both icons as icons to switch back and forth inside the
constructor where I will know which to use.

Please help me undestand if there is an easy way to do this.... I'm sure
there must be.

thanks,

Shane
 
C

Cor

Hi SStory,

I do it in this way, but don't find it nice either, but it is very easy

Private busyIcon As New System.Drawing.Icon("icoBusy.ico")

myIcon = buyIcon

Cor
 
M

Mick Doherty

Add the Icons to the project and set their [Build Action] property to
[Embedded Resource].
Then set the Icon as follows (Where MyNameSpace is the Namespace of your
project and MyIcon.ico is the name of your embedded icon):

\\\
Imports System.Reflection.Assembly

Me.Icon = New Icon(GetExecutingAssembly. _
GetManifestResourceStream( _
"MyNameSpace.MyIcon.ico"))
///

To create an Icon from Bitmap use the following:

\\\
Me.Icon = Icon.FromHandle(MyBitmap.GetHicon)
///
 
S

SStory

hey great answers.... Thanks... I have been wondering how to do this for
some time.

Could you explain the system.reflection.assembly?

Does that just have to do with a program looking at itself?

Ok...

Thanks

Shane



"Mick Doherty"
Add the Icons to the project and set their [Build Action] property to
[Embedded Resource].
Then set the Icon as follows (Where MyNameSpace is the Namespace of your
project and MyIcon.ico is the name of your embedded icon):

\\\
Imports System.Reflection.Assembly

Me.Icon = New Icon(GetExecutingAssembly. _
GetManifestResourceStream( _
"MyNameSpace.MyIcon.ico"))
///

To create an Icon from Bitmap use the following:

\\\
Me.Icon = Icon.FromHandle(MyBitmap.GetHicon)
///

SStory said:
OK... Just don't get it yet....

I have a form and want to use 1 of 2 different icons depending on how it is
called.

If I put my icons in an imagelist, they become bitmaps and can't set the
form

me.icon= to them

seems to be no way to convert from bitmap to icon and can't figure out how
to just store both icons as icons to switch back and forth inside the
constructor where I will know which to use.

Please help me undestand if there is an easy way to do this.... I'm sure
there must be.

thanks,

Shane
 

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

Icon Stash 3
Icon vs BitMap 2
Form Icon at Design Time 2
Resx file 1
Datagrid and Icon 3
Icon problem in .NET 3
[2008] Newbie: Adding Image from Imagelist to Menustrip Item 2
ImageList problem 2

Top