2010-05-23 98 views

回答

54

如果要設置窗體的背景色,以一些任意的RGB值,你可以這樣做:

this.BackColor = Color.FromArgb(255, 232, 232); // this should be pink-ish 
+0

謝謝!非常感謝 – jimmy 2010-05-23 12:52:34

+1

@MusiGenesis它也適用於我,但它說:「構造函數中的虛擬成員調用」,這是什麼意思,我應該做些什麼? :) – radbyx 2012-05-16 10:54:13

+1

@radbyx這是很多月以後,但你的問題的答案在這裏:http://stackoverflow.com/questions/119506/virtual-member-call-in-a-constructor。總之,封閉你的課堂會使警告消失。 – axlj 2016-03-04 21:15:50

8

使用Winforms,你可以使用Form.BackColor來做到這一點。
從窗體的代碼中:

BackColor = Color.LightPink; 

如果你說的是WPF Window你可以使用背景屬性。
從窗口的代碼中:

Background = Brushes.LightPink;