Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Change the icon on the top left of winform

Tags:

winforms

icons

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

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?

like image 540
Coolguy Avatar asked Oct 05 '12 01:10

Coolguy


2 Answers

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.

like image 154
Ofer Zelig Avatar answered Sep 30 '22 00:09

Ofer Zelig


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

    public MainForm()
    {
        InitializeComponent();
        Icon = Icon.ExtractAssociatedIcon(System.Reflection.Assembly.GetExecutingAssembly().Location);
    }
like image 41
Junior Avatar answered Sep 29 '22 23:09

Junior