Embedded icon file - how to reference?

W

Wayne Hoover

I have an embedded icon resource in my project - I need to reference this
icon for a grid cell. I've tried using the following but it does not work. Any
help
appreciated:

Dim im As System.Drawing.Image
im = CType(getobject("CHECKMRK.ICO"),System.Drawing.Image) <-- Fails here.
g_mainform.fg.SetCellImage(g_mainform.FG.Row, 5, im)
 
K

Ken Tucker [MVP]

Hi,

Dim ico As Icon

Dim p As System.Reflection.Assembly =
System.Reflection.Assembly.GetExecutingAssembly()

ico = New System.Drawing.Icon(p.GetManifestResourceStream(Me.GetType,
"Icon1.ico"))



Ken
 
W

Wayne Hoover

Thanks, Ken.

W.

Ken Tucker said:
Hi,

Dim ico As Icon

Dim p As System.Reflection.Assembly =
System.Reflection.Assembly.GetExecutingAssembly()

ico = New System.Drawing.Icon(p.GetManifestResourceStream(Me.GetType,
"Icon1.ico"))



Ken
 
H

Herfried K. Wagner [MVP]

* "Wayne Hoover said:
I have an embedded icon resource in my project - I need to reference this
icon for a grid cell.

Add the icon file to your project and set its 'Build Action' property to
'Embedded Resource'. You can use the code below to load the icon at
runtime:

\\\
foo.Icon = _
New Icon( _
[Assembly].GetExecutingAssembly().GetManifestResourceStream( _
"WindowsApplication1.Ball.ico" _
) _
)
///

'WindowsApplication1' is the root namespace of the application, "Ball.ico"
is the icon's filename.
 
W

Wayne Hoover

Hi Herfried --

I tried the prior response and now get this:

g_mainform.fg.SetCellImage(g_mainform.FG.Row, 5, chkMarkico)

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

Any help appreciated!


Herfried K. Wagner said:
* "Wayne Hoover said:
I have an embedded icon resource in my project - I need to reference this
icon for a grid cell.

Add the icon file to your project and set its 'Build Action' property to
'Embedded Resource'. You can use the code below to load the icon at
runtime:

\\\
foo.Icon = _
New Icon( _
[Assembly].GetExecutingAssembly().GetManifestResourceStream( _
"WindowsApplication1.Ball.ico" _
) _
)
///

'WindowsApplication1' is the root namespace of the application, "Ball.ico"
is the icon's filename.
 
H

Herfried K. Wagner [MVP]

* "Wayne Hoover said:
I tried the prior response and now get this:

g_mainform.fg.SetCellImage(g_mainform.FG.Row, 5, chkMarkico)

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

Any help appreciated!

Icons are not images for .NET! You may want to use a bitmap instead of
an icon.
 

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

Top