Creating ICON no through the properties

G

Guest

Hi,

I want to add icon to my form (on the left corner of the form, where the fom
text is), but i can't use the property window. how can i do it through the
code?

my Icon path now is d:\temp. when i'll finish my project and take the *.exe
file and put it on a different computer, do i have to put my icon file too or
does it complied into the exe file?

Thanks,
Gidi.
 
N

Nicholas Paldino [.NET/C# MVP]

Gidi,

You could place it in the resources for the exe.

If you know that it isn't going to change, then it is better to set it
as a resource for your exe, and then get it from there.

If you have a need to load it from disk, you can just call the static
GetEntryAssembly method on the Assembly class. This will give you the entry
point for your program. Once that is done, you can get the Location
property to find out where your assembly is on disk, and then load your
icon, and set the property on the form.

Hope this helps.
 
G

Guest

Hello Nicholas,

Thanks.

What i want is, that all my forms will have the same ICON or there left
corner (this icon isn't going to change), how can i place it in the resources
for the exe?

Nicholas Paldino said:
Gidi,

You could place it in the resources for the exe.

If you know that it isn't going to change, then it is better to set it
as a resource for your exe, and then get it from there.

If you have a need to load it from disk, you can just call the static
GetEntryAssembly method on the Assembly class. This will give you the entry
point for your program. Once that is done, you can get the Location
property to find out where your assembly is on disk, and then load your
icon, and set the property on the form.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Gidi said:
Hi,

I want to add icon to my form (on the left corner of the form, where the
fom
text is), but i can't use the property window. how can i do it through the
code?

my Icon path now is d:\temp. when i'll finish my project and take the
*.exe
file and put it on a different computer, do i have to put my icon file too
or
does it complied into the exe file?

Thanks,
Gidi.
 
N

Nicholas Paldino [.NET/C# MVP]

Gidi,

If you set the icon to a file on disk, the designer will automatically
place it in a resource file and then load it from that.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Gidi said:
Hello Nicholas,

Thanks.

What i want is, that all my forms will have the same ICON or there left
corner (this icon isn't going to change), how can i place it in the
resources
for the exe?

Nicholas Paldino said:
Gidi,

You could place it in the resources for the exe.

If you know that it isn't going to change, then it is better to set
it
as a resource for your exe, and then get it from there.

If you have a need to load it from disk, you can just call the static
GetEntryAssembly method on the Assembly class. This will give you the
entry
point for your program. Once that is done, you can get the Location
property to find out where your assembly is on disk, and then load your
icon, and set the property on the form.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Gidi said:
Hi,

I want to add icon to my form (on the left corner of the form, where
the
fom
text is), but i can't use the property window. how can i do it through
the
code?

my Icon path now is d:\temp. when i'll finish my project and take the
*.exe
file and put it on a different computer, do i have to put my icon file
too
or
does it complied into the exe file?

Thanks,
Gidi.
 
G

Guest

Nicholas,

I'm sorry, but i don't understand the meaning. do you mean by setting the
icon to a file on disk, that i need to change the icon property in my Form?
becuase as i said, i can't enter the designer mode, i have to do it from the
code, can you please give me an example?

Sorry for nagging,
Gidi.

Nicholas Paldino said:
Gidi,

If you set the icon to a file on disk, the designer will automatically
place it in a resource file and then load it from that.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Gidi said:
Hello Nicholas,

Thanks.

What i want is, that all my forms will have the same ICON or there left
corner (this icon isn't going to change), how can i place it in the
resources
for the exe?

Nicholas Paldino said:
Gidi,

You could place it in the resources for the exe.

If you know that it isn't going to change, then it is better to set
it
as a resource for your exe, and then get it from there.

If you have a need to load it from disk, you can just call the static
GetEntryAssembly method on the Assembly class. This will give you the
entry
point for your program. Once that is done, you can get the Location
property to find out where your assembly is on disk, and then load your
icon, and set the property on the form.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hi,

I want to add icon to my form (on the left corner of the form, where
the
fom
text is), but i can't use the property window. how can i do it through
the
code?

my Icon path now is d:\temp. when i'll finish my project and take the
*.exe
file and put it on a different computer, do i have to put my icon file
too
or
does it complied into the exe file?

Thanks,
Gidi.
 
N

Nicholas Paldino [.NET/C# MVP]

Gidi,

If that is the case, then you can reference my previous post, which
refers you to the GetEntryAssembly method on the Assembly class.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Gidi said:
Nicholas,

I'm sorry, but i don't understand the meaning. do you mean by setting the
icon to a file on disk, that i need to change the icon property in my
Form?
becuase as i said, i can't enter the designer mode, i have to do it from
the
code, can you please give me an example?

Sorry for nagging,
Gidi.

Nicholas Paldino said:
Gidi,

If you set the icon to a file on disk, the designer will
automatically
place it in a resource file and then load it from that.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Gidi said:
Hello Nicholas,

Thanks.

What i want is, that all my forms will have the same ICON or there left
corner (this icon isn't going to change), how can i place it in the
resources
for the exe?

:

Gidi,

You could place it in the resources for the exe.

If you know that it isn't going to change, then it is better to
set
it
as a resource for your exe, and then get it from there.

If you have a need to load it from disk, you can just call the
static
GetEntryAssembly method on the Assembly class. This will give you the
entry
point for your program. Once that is done, you can get the Location
property to find out where your assembly is on disk, and then load
your
icon, and set the property on the form.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hi,

I want to add icon to my form (on the left corner of the form, where
the
fom
text is), but i can't use the property window. how can i do it
through
the
code?

my Icon path now is d:\temp. when i'll finish my project and take
the
*.exe
file and put it on a different computer, do i have to put my icon
file
too
or
does it complied into the exe file?

Thanks,
Gidi.
 

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