Reputation: 25
I was wondering how you would set the icon for the window in c#. I have found answers, but the answer does not involve programming. In visual studio they have an application builder, but I would like to program my application instead. Does anyone know who to accomplish this simple task?
This is what I have so far:
class Program
{
public static void Main(string[] args)
{
Application.Run(new window());
}
}
class Window : System.Windows.Forms.Form
{
public static String Title = "This is a title!";
public Window()
{
this.Size = new Size(640, 480);
this.Text = Title;
}
}
Upvotes: 0
Views: 251
Reputation: 10456
You can do it using the designer:
Icon
row and click on it....
Button.Alternativaly, you can do it in code:
string pathToIcon =@"C:\Path\To\Icon.ico"
this.Icon = new Icon(pathToIcon );
Upvotes: 1
Reputation: 2663
this.Icon = new Icon(@"C:\Folder\IconName.ico");
or if you are embedding the icon in the app:
this.Icon = new Icon(iconStream);
Upvotes: 1