c# how to change the tray icon
-
25-06-2021 - |
سؤال
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'.
المحلول
You have to manually add your newmailIcon.ico
as a resource file in your project.
نصائح أخرى
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.
لا تنتمي إلى StackOverflow