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-timeYou 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.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: