This documentation is archived and is not being maintained.
How to: Set the Background of a Windows Forms Panel
.NET Framework 3.0
A Windows Formscontrol can display both a background color and a background image. The property sets the background color for the contained controls, such as labels and radio buttons. If the property is not set, the BackColor selection will fill the entire panel. If the BackgroundImage property is set, the image will be displayed behind the contained controls.
To set the background programmatically
Set the panel's BackColor property to a value of type.
Set the panel's BackgroundImage property using themethod of the class.
' 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");