Setting background image of button in C#
29,892
Solution 1
You would use this when you load your application, or whenever you want to set it.
button.BackgroundImage = YourApplicationNamespace.Properties.Resources.yourImageHere;
Solution 2
Simply set the BackgroundImage property of the Button. An example:
button1.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.Image));
Solution 3
In Visual Studio, you can do this:
- Go to the properties for your button and click the
BackgroundImage
item. - Click the '...' icon.
- Click the radio button next to 'Local Resource'.
- Click 'Import' and select the item you wish to have as the background.
- Then, click 'Ok'.
Or, from code you can do this:
button1.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.Image));
Author by
TheMrRafus
Updated on November 03, 2020Comments
-
TheMrRafus over 3 years
I want to set an image as background of a button of Windows Forms.
The image is added to the project´s resources.
How do I do this?
-
dsfgsho almost 11 yearsYou're welcome. Please mark the question as answered if it is.