In .NET framework, the Icon class represents a Windows icon, which is a small bitmap image used to represent an object. The icon class is defined in System.Drawing namespace. So before using Icon class, you need to reference the System.Drawing namespace to your application.
You can set icon of a form at run-time as well as at design-time. You use a form's Icon property to set form's icon at design-time. Which actually adds two lines to your source code:
System.Resources.ResourceManager resources = new System.Resources.ResourceManager (typeof(Form1));
this.Icon = (System.Drawing.Icon) resources.GetObject ("$this.Icon");
Creating an Icon Object at run-time
You can can create an icon object at run-time and set it as icon of a Form. You use Icon constructor to create an icon object. The Icon constructor is an overloaded method:
In this sample example, I load tst.ico file as an icon of the form.
System.Drawing.Icon ico = new System.Drawing.Icon("c:\\temp\\tst.ico");
this.Icon = ico ;
You can even set icon's size by using other overloaded constructors.
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.

Joe WilsonPosted Dec 28, 2015, 10:23 AM
Thank you very much.
jishad shaPosted May 20, 2013, 9:23 AM
how can we increase the size of the icon
jishad shaPosted May 20, 2013, 9:21 AM
can we increase the size of the icon.
kalit sikkaPosted Aug 25, 2009, 8:03 AM
How to add Form ICON in WPF