I am trying to use the icon that I added as a resource, like the image on the button. I know this is possible because I can do it in other projects through the designer. However, I am trying to do this with code. I added an icon as a resource to my project by following the steps in the accepted answer to this question . The resource is called CancelButtonIcon.
Now I'm trying to add this icon as an image of a standard button using this code:
this.CancelButton.Image = (System.Drawing.Image)Properties.Resources.CancelButtonIcon;
However, I get an error message:
Cannot convert type 'System.Drawing.Icon' to 'System.Drawing.Image'
In the code that Visual Studio automatically creates when using the constructor, it looks like this:
((System.Drawing.Image)(resources.GetObject("SaveButton.Image")));
"". , ? ( , , ).