WinForms – How to remove icon from form/taskbar

Here’s the quick way to remove an icon from a WinForm:

  1. Open the form properties.
  2. Right-click on Icon.
  3. Click Reset.
Form Properties > right-click Icon > click Reset

It’ll revert to the default icon.

Removing an icon without the UI

You may be interested in how to remove an icon without going through the Visual Studio UI. You may want to remove the icon manually, or you may be trying to figure out a way to programmatically remove an icon from a bunch of forms.

To remove an icon without the UI, first, let’s take a look at how an icon is stored and referenced.

How an icon is stored and referenced

Let’s say your form is called frmMain. When you add an icon to this form, it saves the base64-encoded image into frmMain.resx, and refers to this icon in frmMain.Designer.cs.

Here’s a look at frmMain.resx. It has this <data> node with your icon represented as a base64-encoded string, and it has the name $this.Icon.

<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
	huge base64 string
</value>
</data>
Code language: HTML, XML (xml)

And here’s frmMain.Designer.cs. It sets the icon to the embedded resource $this.Icon.

private void InitializeComponent()
{
	System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmMain));
	this.SuspendLayout();
	// 
	// frmMain
	// 
	this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
	this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
	this.ClientSize = new System.Drawing.Size(800, 450);
	this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
	this.Name = "frmMain";
	this.Text = "Main";
	this.ResumeLayout(false);

}
Code language: C# (cs)

Now you know how the icon is stored and referenced, and you can manually (or programmatically) remove or replace the icon.

How to manually remove the icon

  1. Remove the line in frmMain.Designer.cs where it’s setting the icon.
  2. Using Notepad, delete the <data> node with the name $this.Icon from frmMain.resx.

Now the icon is gone and it reverted back to the default.

Leave a Comment