HOW TO:設定 Windows Form 面板的背景
Windows Form Panel 控制項可顯示背景色彩和背景影像。 BackColor 屬性設定被收納的控制項 (Contained Control) 之背景色彩,如標籤 (Label) 和選項按鈕。 如果 BackgroundImage 屬性未設定,則選取的 BackColor 會填滿整個面板。 如果設定了 BackgroundImage 屬性,則影像會顯示在被收納的控制項之後。
若要以程式設計的方式來設定背景
設定面板的 BackColor 屬性為 System.Drawing.Color 型別的值。
Panel1.BackColor = Color.AliceBlue
panel1.BackColor = Color.AliceBlue;
panel1->BackColor = Color::AliceBlue;
使用 System.Drawing.Image 類別的 FromFile 方法,設定面板的 BackgroundImage 屬性。
' You should replace the bolded image ' in the sample below with an image of your own choosing. Panel1.BackgroundImage = Image.FromFile _ (System.Environment.GetFolderPath _ (System.Environment.SpecialFolder.Personal) _ & "\Image.gif")
// You should replace the bolded image // in the sample below with an image of your own choosing. // Note the escape character used (@) when specifying the path. panel1.BackgroundImage = Image.FromFile (System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal) + @"\Image.gif");
// You should replace the bolded image // in the sample below with an image of your own choosing. panel1->BackgroundImage = Image::FromFile(String::Concat( System::Environment::GetFolderPath (System::Environment::SpecialFolder::Personal), "\\Image.gif"));