adding Icons as a part of my project and use them

  • Thread starter Thread starter Gidi
  • Start date Start date
G

Gidi

Hi,

In my application i'm using two different icons which being displayed in
different occasions. how can i add this Icons to my project, so when i'll
bring my exe file to another machine, the project will recognize these icons?

and after doing it, how can i use them in my project?

Thanks,
Gidi.
 
Hi,

In my application i'm using two different icons which being displayed in
different occasions. how can i add this Icons to my project, so when i'll
bring my exe file to another machine, the project will recognize these icons?

and after doing it, how can i use them in my project?

Thanks,
Gidi.

you can add them as embedded resources (I think it's the default)
but what you want to do with them? where r u going to use them?
 
Hi,

Thanks,

i read the article, did all the steps, and now my icon files are Embedded
Resource, but i can't understand how do i call them and set them as an images.

can you assist?

Thanks,
Gidi,
 
Hi Gidi,

You can acquire them using the following code:

Stream manifestStr =
System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("YourNamespace.IconFileName");
// Always ensure that the returned stream is non-null in order to avoid
exceptions
if (manifestStr != null)
{
Icon myIcon = new Icon(manifestStr);

// Assuming this is executed in the scope of a Form, change its icon, or
do anything else with it
this.Icon = myIcon;

manifestStr.Close();
}

It is important to understand how manifest resource names are generated. You
should include the root namespace that you can find in your project's
properties, separate it with a dot and include your icon file name.

Hope this helps,
Stanimir Stoyanov | www.stoyanoff.info
 
Back
Top