"bind" icon-file to form/notifyicon
Hello! I have a form and a notify-icon and both of them have an associated ico-file. When changing the ico-file, you have to go to the properties and choose the icon again in order to make the changes effective.
Is there any way to tell Visual-Studio to "bind" the icon to the icon-file, so when rebuilding the project the icon refreshes from the file if it has been changed?
Re: "bind" icon-file to form/notifyicon
How about adding the icon as a resource, as described here :
http://support.microsoft.com/default.aspx/kb/324567
¿
What version of .NET do you have ¿
Re: "bind" icon-file to form/notifyicon
Thanks for your fast reply. The icon was already added to the solution-explorer. So in the Properties Window, I set the build action to "embeded resource" - but still the icon is not changed (even when rebuilding the whole project). Any ideas about that?
Re: "bind" icon-file to form/notifyicon
You see, the whole problem is :
When you add a resource to your project, a copy is made, and stored in a different place than what it was originally. When you change the file ( where you have last saved it ), the project still has a copy of the old version saved.
What I want to suggest is to delete the resource from your project, and remove it from the form, and the NotifyIcon, so all references to it. Then, at form load, just set the icon for bot the form as well as the notifyicon through code :
Code:
private void Form1_Load(object sender, EventArgs e)
{
this.Icon = Icon.ExtractAssociatedIcon("Adriaan.ico");
notifyIcon1.Icon = Icon.ExtractAssociatedIcon("Adriaan.ico");
}
I hope my info was helpful! :)
Re: "bind" icon-file to form/notifyicon
Thanks again for your reply. But when I use ExtractAssociatedIcon and distribute the application I would have to add the icon-files, right? That would be a disadvantage.
You say that a copy is made - where is this copy stored? Because I couldn't find it. But if I could locate it I could just edit the copy to take effect in the next build.
Re: "bind" icon-file to form/notifyicon
Quote:
Originally Posted by
martho
Thanks again for your reply. But when I use ExtractAssociatedIcon and distribute the application I would have to add the icon-files, right? That would be a disadvantage.
Well, it is part of your project, a resource then would also be a disadvantage. Icon files are small in size. But still, I agree not having it deployed with, because it may get deleted etc. Will the icon file change often ¿ Or is it just now that its changing so much ¿
Quote:
Originally Posted by
martho
You say that a copy is made - where is this copy stored? Because I couldn't find it.
Mine is stored inside my solution folder, where you see the .csproj and cs files.
Quote:
Originally Posted by
martho
But if I could locate it I could just edit the copy to take effect in the next build.
That may also not work
Re: "bind" icon-file to form/notifyicon
Quote:
Originally Posted by
HanneSThEGreaT
Well, it is part of your project, a resource then would also be a disadvantage. Icon files are small in size. But still, I agree not having it deployed with, because it may get deleted etc. Will the icon file change often ¿ Or is it just now that its changing so much ¿
It's just while developing you see that the icon doesn't fit, so you change it, and I want to see the result quickly - and it drives you crazy to set the icon every time.
Quote:
Originally Posted by
HanneSThEGreaT
Mine is stored inside my solution folder, where you see the .csproj and cs files.
Mine, too...
Re: "bind" icon-file to form/notifyicon
Quote:
Originally Posted by
martho
It's just while developing you see that the icon doesn't fit, so you change it, and I want to see the result quickly - and it drives you crazy to set the icon every time.
Yep, True words! :D
It's usually the small things that give the biggest headaches! LOL! :lol:
Re: "bind" icon-file to form/notifyicon
Thanks a lot - it helps to see someone suffering just the same ;-)