2012-04-18 101 views
5

我的目标是更改背景图片并将其SizeMode设置为拉伸。 迄今尝试了很多,有什么想法?更改图片框中背景图片的大小模式

编辑:我在C#窗体应用程序工作。 BG图片试图简单地设置大小模式:

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

试图在BackgroundImageLayout走动它......没有成功...

+1

Windows窗体? WPF? Web窗体? Silverlight的? – 2012-04-18 14:14:07

+1

如果您希望标题说明一切,则不应将它用“C#Forms”作为前缀。这就是标签的用途。 – 2012-04-18 14:14:47

+0

PictureBoxSizeMode,BackgroundImageLayout是用于相同目的的不同枚举。 .NET一致性... – Larry 2012-09-14 07:33:48

回答

15

看。
例如:

whatever.BackgroundImageLayout = ImageLayout.Stretch 
+0

非常感谢。 – 2012-04-18 14:21:02

+1

不客气。下次尝试更具体一些,并展示从一开始就尝试过的内容。它使我们更容易帮助你。这就是你想要的。 ;) – Skalli 2012-04-18 14:27:03

+1

使用this = whatever // this.BackgroundImageLayout = ImageLayout.Stretch; – jmozko 2015-09-27 06:15:02