Embedded icon file - how to reference? by: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)
|
| | Reply: by: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
|
| | Reply: by:Wayne Hoover
|
| | Thanks, Ken.
|
| | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
|
| | 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.
-- Herfried K. Wagner [MVP] URL:http://dotnet.mvps.org/
|
| | Reply: by: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!
|
| | Reply: by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])
|
| | Icons are not images for .NET! You may want to use a bitmap instead of an icon.
-- Herfried K. Wagner [MVP] URL:http://dotnet.mvps.org/
|
0 Comments:
Post a Comment
<< Home