Clayton
Clayton

Reputation: 133

Panel Background Image Repetition C#

I want to place an image in a panel, but I do not want it repeated according to the size of the panel.

What I did is this:

panel3.BackgroundImage = picture1;

However, picture1 is repeated several times, since the panel is much wider than the actual picture.

What I want is to display the picture in its original form only. I don't want it repeated.

How can I do this? Thanks

Upvotes: 3

Views: 17959

Answers (3)

hossam
hossam

Reputation: 81

ImageLayout.Stretch; //make Image Fill the Control 
ImageLayout.None; //just put the image without any changes on size
ImageLayout.Center; //adjust location of image to be centered
ImageLayout.Tile; //repeat image
ImageLayout.Zoom; //re size image to be all viewed in the control (without stretch)

Upvotes: 8

Pieter van Ginkel
Pieter van Ginkel

Reputation: 29642

You can set BackgroundImageLayout to Center.

Upvotes: 1

Haris Hasan
Haris Hasan

Reputation: 30097

try

panel3.BackgroundImageLayout = ImageLayout.Stretch;

this will stop repeatition and will stretch image to whole panel. If you don't want image to stretch Try ImageLayout.Center

Upvotes: 6

Related Questions