Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between BackgroundImage and Image of a button?

I have a simple question, if I have a button called myButton in Windows Forms, what is the difference of myButton.Image and myButton.BackgroundImage? Thank you in advance!

like image 338
Michel Feinstein Avatar asked May 31 '12 01:05

Michel Feinstein


2 Answers

BackgroundImage is like wallpaper, it covers the whole background.. you should use patterns or full pictures for the background. If you are just trying to show an icon use Button.Image

For the Button.Image property from MS documentation:

The Image displayed on the button control.

The BackgroundImage

An Image that represents the image to display in the background of the control.

So you can set a BackgoundImage as well as a Button.Image the Button.Image will be placed over top of the BackgroundImage

Note: Images with translucent or transparent colors are not supported by Windows Forms controls as background images. This property is not supported on child controls whose RightToLeftLayout property is true.

Here is an example I just created of a Button with both BackgroundImage and Button.Image set. Clearly there is a background image, then my button text and a button image next to my text.

BackGroundImage with Button.image

The cool thing is you can change where you place your Button.Image with the ImageAlign property

ImageAlign

Here's the same button using an icon with transparency and NOT using RTL and I set the background color to light blue and it all works fine. So either my icon with transparency really isn't transparent or the docs are wrong.

enter image description here

like image 165
CD Smith Avatar answered Nov 20 '22 06:11

CD Smith


Background Image - The image as in the name suggests, gets set in the background and the text comes over it.

Image - The Image is adjacent(side-by side) to Text provided. (See in Image)

enter image description here

like image 39
Nikhil Agrawal Avatar answered Nov 20 '22 07:11

Nikhil Agrawal