简体   繁体   English

面板背景图像重复C#

[英]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. 但是,picture1重复几次,因为面板比实际图片宽得多。

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 谢谢

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)

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 如果您不想要图像拉伸尝试ImageLayout.Center

您可以将BackgroundImageLayout设置为Center

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM