如何:設定 Windows Form 面板的背景
Windows Forms Panel 控制項可以同時顯示背景色彩和背景影像。 屬性 BackColor 會設定自主控制項的背景色彩,例如標籤和選項按鈕。 BackgroundImage如果未設定 屬性,選取 BackColor 專案將會填滿整個面板。 BackgroundImage如果已設定 屬性,則會在自主控制項後面顯示影像。
以程式設計方式設定背景
將面板的 BackColor 屬性設定為 類型的 System.Drawing.Color 值。
Panel1.BackColor = Color.AliceBlue
panel1.BackColor = Color.AliceBlue;
panel1->BackColor = Color::AliceBlue;
使用 FromFile 類別的 方法設定面板 BackgroundImage 的屬性 System.Drawing.Image 。
' 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"));
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應