2012-04-18 90 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