C# - Changing the icon of the taskbar

51,798

Solution 1

You need to give your form that icon as well. The application icon is the one that is embedded in the application and displayed in Explorer or on shortcuts. Each form can have its own icon, though.

Solution 2

I've noticed a couple of things with Windows 7 and Windows 8. The Windows Taskbar icon is taken from the programs Shortcut's icon, not the applications icon.

If you assign your application an Icon through Visual Studio it will set an icon that appears in the form as well as in the notification area. However the taskbar icon and any shortcut's you create will not take the icon from the application, as they used to, instead they are created with the default shortcut icon.

So I found that I had to set up the Shortcut icon's (that lives in the Start Menu) as part of my installer for the application.

I don't have to do this for Windows XP.

Solution 3

1 - Add a file (e.g. Address_Book.ico) to Resources section

2 - Add follow lines in your code

   public Form1()
   {
       ....
       this.Icon = Properties.Resources.Address_Book;
   }

3 - It Works.

Solution 4

Set the Form.Icon Property through code also consider the below suggestion from MSDN

A form's icon designates the picture that represents the form in the taskbar as well as the icon that is displayed for the control box of the form. This property will have no effect if FormBorderStyle is set to FixedDialog. In that case, the form will not display an icon.

Solution 5

You will require to use notifyicon component from toolbox. Please follow the instructions as given below.

TaskBar with the Windows Forms NotifyIcon Component

Share:
51,798
loomie
Author by

loomie

Updated on January 23, 2020

Comments

  • loomie
    loomie over 4 years

    I want to change the icon on the taskbar of my software, so I changed the project settings. This path was suggested by Visual Studio itself

    Path to the icon

    But my taskbar still shows the same icon as before (the standard one) - In my Explorer the .exe has the correct icon, it just won't change in the taskbar.

    I also tried to end explorer.exe and restart the task, but this didn't help at all. I also tried to set the resolution on 16x16 and 32x32 but both didn't work.

  • loomie
    loomie about 11 years
    Now I'm feeling like an idiot. Thanks. I thought when I change it in the Project properties it will do it itself.
  • mschr
    mschr almost 8 years
    I second this, it somewhat applies to win10 too. Weird as it may be - while the application is Not pinned to taskbar in Windows 10, the Form.Icon is applied, but default .exe is used if an uninstalled app without shortcut icon is pinned
  • MrDysprosium
    MrDysprosium over 7 years
    Can someone elaborate on this? What do you mean the "form" needs the icon as well? How do I change that if I have already changed the icon in project > properties > application > icon ?
  • Andrey Moiseev
    Andrey Moiseev over 7 years
    Moreover, in Windows 10 you can try to launch the exe directly from Program Files and it uses desktop shortcut icon for taskbar, not the app icon of form icon.
  • C J
    C J almost 2 years
    This method does not work in all instances. I have an application that is launched as a minimized app in startup and dynamically sets the main forms icon. This defaults to the cached icon and not the current icon set for the main window. Same for apps pinned to the taskbar.