JimDel
JimDel

Reputation: 4359

How can I make a notifyicon in C# alternate between two icons?

Im using VS2010 with C# and a WinForm. When a certain condition is met, I would like the notifyicon in C# alternate between two icons. I see that the code below is created for a single icon but I can't see how to programmatically change it. The "((System.Drawing.Icon)(resources.GetObject("notifyIcon.Icon")))" part doesn't make sense to me.

notifyIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon.Icon")));

I tried...

notifyIcon.Icon = (System.Drawing.Icon(Application.StartupPath + @"\noneed.ico"));

but wont work. I get the error "System.Drawing.Icon' is a 'type', which is not valid in the given context"

Thanks for the help

Upvotes: 1

Views: 7363

Answers (1)

bkr
bkr

Reputation: 1484

you forget to add a new keyword:

notifyIcon.Icon = new System.Drawing.Icon( Application.StartupPath + @"\noneed.ico" );

Upvotes: 6

Related Questions