Reputation: 83
I want load icon from Resources
.
I am using code:
Resources.myImage
It is Bitmap
.
I need:
System.Windows.Forms.NotifyIcon
.
How can I load image like a System.Windows.Forms.NotifyIcon
or use some convert?
Thank you for your help.
Upvotes: 0
Views: 2921
Reputation: 81
If you want to use the System.Windows.Forms.NotifyIcon
, you have to set the icon first. You could use one of the ones in SystemIcons
, for example: var myInformationIcon = SystemIcons.Information;
If u want to use your own icons u have to convert your bitmap to an .ico-file.
Convert a Bitmap to an Icon with C#, have a look at this example Bitmap_to_Icon
Upvotes: 1
Reputation: 980
Sounds like you are trying to set the image of the NotifyIcon. NotifyIcon is a WinForm control. When you drag it onto your Form you are basically creating an instance of the NotifyIcon class which has several properties.
One of the properties of the NotifyIcon control is called Icon which lets you set the icon that gets displayed in the notification area. Generally you can set this straight from the IDE but if you are trying to set it programmatically using a .ico file you have in your resources then you can do the following:
this.notifyIcon1.Icon = MyProjectName.Properties.Resources.MyIconName;
Upvotes: 3
Reputation: 15151
NotifyIcon is the class to show an icon on the tray, not the icon per se.
NotifyIcon has a property named Icon, that's what you want to set, create a new NotifyIcon and then set it's Icon property to the resource.
Also, remember Icon is of type "Icon", not "Bitmap", you need a .ico file.
Upvotes: 1