C# Change the icon on the top left of winform

非 Y 不嫁゛ 提交于 2019-12-21 03:19:08

问题


I'm trying to change the top left corner icon of the winform from the default one to my icon:

I've tried it by going to the Properties of my project, and go into Application, the set my own icon it in "Icon and Manifest".

But after that, it still show the same old default icon. Is there something I done wrong?


回答1:


Your form has properties associated with it (in design mode, have the focus on your form and click F4). One of the properties is Icon and this is what you're looking for.

The icon you are referring to, in Application Properties, is the icon that will be used in the .EXE generated file.




回答2:


You can use the icon setted for application using the following code:

    public MainForm()
    {
        InitializeComponent();
        Icon = Icon.ExtractAssociatedIcon(System.Reflection.Assembly.GetExecutingAssembly().Location);
    }



回答3:


It's quite easy; just right-click your window in the visual studio designer and click on settings then navigate in the settings sidebar to the icon section - click on the three dots and select a .ico file as your icon to be displayed in the top left corner of you application.



来源:https://stackoverflow.com/questions/12738312/c-sharp-change-the-icon-on-the-top-left-of-winform

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!