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:

  1. Go to the properties for your button and click the BackgroundImage item.
  2. Click the '...' icon.
  3. Click the radio button next to 'Local Resource'.
  4. Click 'Import' and select the item you wish to have as the background.
  5. Then, click 'Ok'.

Or, from code you can do this:

button1.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.Image));
Share:
29,892
TheMrRafus
Author by

TheMrRafus

Updated on November 03, 2020

Comments

  • TheMrRafus
    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
    dsfgsho almost 11 years
    You're welcome. Please mark the question as answered if it is.