Icon from ressource

T

Te-Deum

Hi,

I want to use icons that is loaded in ressource, but I don't know how to do
it ?
I use this function to load icon from file : Dim NewIcon As New
Icon("MyIcon.ico")

Thank's for your help.

Te-Deum.
 
H

Herfried K. Wagner [MVP]

Hello,

Te-Deum said:
I want to use icons that is loaded in ressource, but I don't know how to do
it ?

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.

HTH,
Herfried K. Wagner
 
T

Te-Deum

I try your solution, but it doesn't work.
Dim NewIcon As Icon
NewIcon = New
Icon([Assembly].GetExecutingAssembly().GetManifestResourceStream("MyApp.List
e.ico"))

I must add this line to recognize [Assembly] :
Imports System
Imports System.Reflection

The error come on the line : NewIcon = New Icon(...

Thank's for your help.
 

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