Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,889 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I'm trying to programmatically set my program's icons in code using an icon in the resources in C#. This code here doesn't work:
System.ComponentModel.ComponentResourceManager resources2 = new System.ComponentModel.ComponentResourceManager(typeof(TLS_FormMain));
this.Icon = (Icon)(resources2.GetObject("TLS_Icon_Green.ico"));
Neither does this code:
Icon programIcon = new Icon(typeof(TLS_FormMain), "TLS_Icon_Green.ico");
this.Icon = programIcon;
Any solutions?
With an icon resource named Test2, this simple line works for me :
this.Icon = Properties.Resources.Test2;