Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the sizemode of a background image in picturebox

My aim was to change the background image and set it's SizeMode as Stretch. Tried a lot so far, any ideas?

EDIT: I am working in C# forms application. Tried simply setting size mode of bg picture:

picturebox1.BackgroundImage = Properties.Resources.Image;
picturebox1.SizeMode = PictureBoxSizeMode.StretchImage;

tried to move around it... no success...

like image 369
Antonio Teh Sumtin Avatar asked Apr 18 '12 14:04

Antonio Teh Sumtin


People also ask

How do I set the sizemode of A PictureBox?

PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; } Use the members of this enumeration to set the value of the SizeMode property of the PictureBox. Initializes a new Font that uses the specified existing Font and FontStyle.

How do I change the size of my image?

You can change the size of your image by using percentages. In our example, we use the length value where the first value sets the width and the second one sets the height.

How is the PictureBox sized?

The PictureBox is sized equal to the size of the image that it contains. The image is displayed in the center if the PictureBox is larger than the image. If the image is larger than the PictureBox, the picture is placed in the center of the PictureBox and the outside edges are clipped. The image is placed in the upper-left corner of the PictureBox.

How to change the size of a background image using percentages?

You can change the size of your image by using percentages. In our example, we use the length value where the first value sets the width and the second one sets the height. Let’s bring the code parts together and see the result! Let’s see another example where we use percentages for setting the background image size.


1 Answers

Look at BackgroundImageLayout.
Example:

whatever.BackgroundImageLayout = ImageLayout.Stretch
like image 175
Skalli Avatar answered Oct 01 '22 15:10

Skalli