473,320 Members | 1,955 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Embedded icon file - how to reference?

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.Ima ge) <-- Fails here.
g_mainform.fg.SetCellImage(g_mainform.FG.Row, 5, im)
Nov 20 '05 #1
5 2494
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

----------------------

"Wayne Hoover" <wh*****@noemail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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.Ima ge) <-- Fails here.
g_mainform.fg.SetCellImage(g_mainform.FG.Row, 5, im)

Nov 20 '05 #2
Thanks, Ken.

W.

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:e9**************@TK2MSFTNGP10.phx.gbl...
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

----------------------

"Wayne Hoover" <wh*****@noemail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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.Ima ge) <-- Fails here.
g_mainform.fg.SetCellImage(g_mainform.FG.Row, 5, im)


Nov 20 '05 #3
* "Wayne Hoover" <wh*****@noemail.com> scripsit:
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.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4
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 [MVP]" <hi***************@gmx.at> wrote in message
news:c4*************@ID-208219.news.uni-berlin.de...
* "Wayne Hoover" <wh*****@noemail.com> scripsit:
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.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #5
* "Wayne Hoover" <wh*****@noemail.com> scripsit:
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.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jack | last post by:
I was learning Windows programming in C# using Charles Petzold book, but this book was written for the older version of .NET. The example of using icon from embedded resource fails to work when...
3
by: Rogerio Jun | last post by:
Can I copy a embedded resource icon from a DLL to ohter DLL ? Rogerio
0
by: carl.manaster | last post by:
Hi, In <http://groups-beta.google.com/group/microsoft.public.dotnet.languages.csharp/msg/05abaf8460c61859>, back in 2003, "SleazySt" wrote that > Unfortunately, C# projects can't have...
2
by: Brian Henry | last post by:
If you embedded an icon into a dll, how would you get access to it form inside the dll and return it to the calling app? I know how to return it, just I cant figure out how to access the embedded...
8
by: Wayne Hoover | last post by:
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...
8
by: news.microsoft.com | last post by:
I have an icon that I can reference by the following: Dim im As System.Drawing.Image im = im.FromFile(lsapppath & "ChkMrk.ico") g_mainform.fg.SetCellImage(g_mainform.FG.Row, 5, im) The problem...
11
by: Garrett | last post by:
I'm fairly new to VB .NET and programming in general, and I want to give my program its own icon without it being a separate file. I have the icon as part of the project, and its Build Action is...
2
by: Pippo | last post by:
I've created a c# dll with some classes and i've included some icons that i can see with ILDASM like namespace.iconfile.ico I re-use this dll (dll reference) and relative classes in many vb...
6
by: farseer | last post by:
Hi, I created a new resouce ("app.resx") in my project and added an icon to this resource with name "IL_ICON". I would like to use this resource in some unmanaged code, in particular, with the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.