I was able to swap Icons, both using the Resources example and this
approach:
string str1 = @"C:\Data\My Stuff\Images\Cars\untitled.bmp";
string str2 = @"C:\Data\My Stuff\Documents\ebay.txt";
bool flip;
void button1_Click(object sender, EventArgs e) {
if (flip)
notifyIcon1.Icon =
System.Drawing.Icon.ExtractAssociatedIcon(str1);
else
notifyIcon1.Icon =
System.Drawing.Icon.ExtractAssociatedIcon(str2);
flip = !flip;
}
Of course you could just load up the icon using the constructor, but I
didn't have any icon files available. The important part is that I'm
doing it when you click the button, and I'm setting the Icon property
of the NotifiyIcon object.
> I was experimenting with thisiconproblem and had a very difficult
> time attempting to reload anothericonfile for aNotifyIconcontrol.
> My problem was that I kept getting involved with the resouce file
> which is very extensive and written in xml. After about an hour of
> messing with this, I can up with a much simpler solution.
>
> I added twoNotifyIconcontrols and simply swapped the visible state
> (true or false) between the two icons. This worked very well.
>
> If you find another way involving reassigning theiconto a simple
> control, I am very interested in hearing how you did it.
>
> Thanks,
>
> Kevin O'Connell
>
> On Aug 29, 9:00 am, Kevin Hunter <
mathwiz...@gmail.com> wrote:
>
> > OK, here is my problem
>
> > i am currently making a program that involves aNotifyIcon. i can
> > manly change theicon(before the program runs in the properties
> > window) with no problem, but what i need is a way to have the program
> > change itsiconmid-stream.
>
> > i have already make toiconfiles: let's call them icon1.ico and
> > icon2.ico. i also have a (working)NotifyIcon, and we'll call that
> > NotifyIcon1 (these are all default names).
>
> > i have tried other things like NotifyIcon1.add("TheIconLocation"),
> > but that just ADDS the newiconto the notification area, and will not