问题
I have assigned an icon to my application from the Properties window in Solution Explorer in Visual Studio; the application's icon changed successfully but the title bar is still showing the default icon:
I've rebuilt my application but it still displays the default icon. What am I doing wrong?
回答1:
Because forms have a different icaon configuration than the application. Set the icon on the form, not ONLY on the application.
回答2:
The form itself has an Icon
property you need to set as well.
回答3:
I know that it is a very old issue but I can add the following comment :
Pay attention to the 'FormBorderStyle' property. If 'FixedToolWindow' or 'SizableToolWindow' are selected, your icon will not appear, even if you specified an icon in the 'Icon' property. I encountered the same issue. Good luck.
回答4:
There is another reason why the icon might not show.
If the ControlBox property of the Form is set to False the icon will not show.
(Sounds like an undesired side effect)
回答5:
If you using winform you need to set the icon property of your main form
回答6:
You didn't mention if you are using winforms or wpf - wpf will place the icon on all windows/forms unless overridden.
Winforms requires individually set icons.
来源:https://stackoverflow.com/questions/14547969/why-does-my-icon-not-appear-in-the-title-bar