By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,723 Members | 828 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,723 IT Pros & Developers. It's quick & easy.

HOWTO: Set this.Icon to App.ico in a windows form

P: n/a
How do you set the this.Icon property of a windows form to the App.ico file
specified in the Project Properties? I don't want to type in the path and
filename; I want to set the form's icon programmatically in the Form Load
section.

--

Thank you kindly,

Dan Sikorsky MSCS, BSCE, BAB


Nov 16 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi,

Try this...

System.Drawing.Icon ico = new System.Drawing.Icon("C:\\soaf.ico");
this.Icon = ico;

Hope this helps...

Cheers,
Madhu

"Dan Sikorsky" wrote:
How do you set the this.Icon property of a windows form to the App.ico file
specified in the Project Properties? I don't want to type in the path and
filename; I want to set the form's icon programmatically in the Form Load
section.

--

Thank you kindly,

Dan Sikorsky MSCS, BSCE, BAB


Nov 16 '05 #2

P: n/a
First you need to set the BuildAction property of the App.ico file to
Embedded resource, then you can use the ResourceManager class to set the
icon for your form.

Let me know if you get stuck.

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph

Dan Sikorsky wrote:
How do you set the this.Icon property of a windows form to the App.ico file
specified in the Project Properties? I don't want to type in the path and
filename; I want to set the form's icon programmatically in the Form Load
section.

Nov 16 '05 #3

P: n/a
Thanks ... this works good.

--

Thank you kindly,

Dan Sikorsky MSCS, BSCE, BAB

"Sijin Joseph" <si***************@hotmail.com> wrote in message
news:OK**************@TK2MSFTNGP09.phx.gbl...
First you need to set the BuildAction property of the App.ico file to
Embedded resource, then you can use the ResourceManager class to set the
icon for your form.

Let me know if you get stuck.

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph

Dan Sikorsky wrote:
How do you set the this.Icon property of a windows form to the App.ico file specified in the Project Properties? I don't want to type in the path and filename; I want to set the form's icon programmatically in the Form Load section.

Nov 16 '05 #4

P: n/a
Thanks for the example, but I explicitly requested a different solution:
How do you set the this.Icon property of a windows form to the App.ico file specified in the Project Properties? I DON'T WANT TO TYPE IN THE PATH AND FILENAME; I want to set the form's icon programmatically in the Form Load
section.
--

Thank you kindly,

Dan Sikorsky MSCS, BSCE, BAB

"Madhu[C#-MVP]" <Ma*******@discussions.microsoft.com> wrote in message
news:41**********************************@microsof t.com... Hi,

Try this...

System.Drawing.Icon ico = new System.Drawing.Icon("C:\\soaf.ico");
this.Icon = ico;

Hope this helps...

Cheers,
Madhu

"Dan Sikorsky" wrote:
How do you set the this.Icon property of a windows form to the App.ico file specified in the Project Properties? I don't want to type in the path and filename; I want to set the form's icon programmatically in the Form Load section.

--

Thank you kindly,

Dan Sikorsky MSCS, BSCE, BAB


Nov 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.