简体   繁体   中英

c# how to change the tray icon

I'm still learning C# and I'm stuck. My problem is that I have a tray icon, which has to be changed when somthing happens.

I have added the new icon as an existing item to the project and I'm trying to change it by using this code:

this.notifyIcon1.Icon = new Icon(GetType(), "newmailIcon.ico");

But I'm getting the following error:

Resource 'newmailIcon.ico' cannot be found in class 'Traym_Icon.Form1'.

您必须手动将newmailIcon.ico添加为项目中的资源文件。

right click on your image, click propereties and at the Build action, choose Embed.

or create a .resx in which you will keep your icons.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM