Reputation: 616
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
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.
Upvotes: 24
Views: 66126
Reputation: 354794
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.
In the Form Designer view, Scroll down to Window Style and you will find the option to set the icon there.
Here is an example of this section in Rider:
Upvotes: 56
Reputation: 173
The taskbar icon will not change when the forms icon is set after start up when:
I have an app that falls into category 2. It is in the windows startup group and starts minimized. Without jumping trough hoops and changing to using overlays the simplest solution was to create a simple 1 line app that then launch's my app.
Process.Start(appName);
This app is in the startup group and when it launches my main application the taskbar icon does follow the forms current icon setting.
Upvotes: 0
Reputation: 2780
You will require to use notifyicon component from toolbox. Please follow the instructions as given below.
TaskBar with the Windows Forms NotifyIcon Component
Upvotes: 2
Reputation: 227
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.
Upvotes: 9
Reputation: 10552
The icon set in the project properties is the icon of the executable and not the icon in the taskbar, the icon in the taskbar is the icon from the current form.
If you have multiple forms with the same icon and you set the icon of a form using the GUI then it will add multiple instances of the icon into the compiled executable file, this will lead to a larger compiled executable.
So you should put this Icon = Properties.Resources.icon;
in the constructor of each form to set the icon of the form.
As for the icon size, im not sure what the max size is but i use 128x128 icon files.
Upvotes: 0
Reputation: 3101
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.
Upvotes: 15
Reputation: 2673
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.
Upvotes: 5