I have an C# app. I need to add an icon to that app so i added an icon resource. Adding resource went fine, but is there any way to use my (resource) icon as form icon WITHOUT adding additional code? When i try to use design-time "icon" property of form it seems i have to choose a file, but i want to use embedded icon...
Any help?
Just right click on your project-> add-> resource. Add resource window would have popped up where in you can select icon as your preference and select import. Then it lets you to browse through your directory and select your icon.
On the menu bar, choose Project > Properties. When the Project Designer appears, choose the Application tab. (Visual Basic)—In the Icon list, choose an icon (. ico) file.
Add the icon to the project resources and rename to icon.
Open the designer of the form you want to add the icon to.
Append the InitializeComponent function.
Add this line in the top:
this.Icon = PROJECTNAME.Properties.Resources.icon;
repeat step 4 for any forms in your project you want to update
How I load Icons: Using Visual Studio 2010: Go to the project properties, click Add Resource > Existing File, select your Icon.
You'll see that a Resources folder appeared. This was my problem, I had to click the loaded icon (in Resources directory), and set "Copy to Output Directory" to "Copy always". (was set "Do not copy").
Now simply do:
Icon myIcon = new Icon("Resources/myIcon.ico");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With