--- title: Set the Background of a Panel description: Learn how to set the background color and background image of a Windows Forms panel using the Designer. ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" - "cpp" helpviewer_keywords: - "background colors [Windows Forms], Windows Forms Panel controls" - "background images [Windows Forms], Windows Forms Panel controls" - "Panel control [Windows Forms], background" - "colors [Windows Forms], Windows Forms Panel controls" ms.assetid: 096cbd8d-45cc-47b8-b1ef-a27f60ea8be0 --- # How to: Set the Background of a Windows Forms Panel A Windows Forms control 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 selection will fill the entire panel. If the property is set, the image will be displayed behind the contained controls. ### To set the background programmatically 1. Set the panel's property to a value of type . ```vb Panel1.BackColor = Color.AliceBlue ``` ```csharp panel1.BackColor = Color.AliceBlue; ``` ```cpp panel1->BackColor = Color::AliceBlue; ``` 2. Set the panel's property using the method of the class. ```vb ' 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") ``` ```csharp // 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"); ``` ```cpp // 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")); ``` ## See also - - - [Panel Control](panel-control-windows-forms.md) - [Panel Control Overview](panel-control-overview-windows-forms.md)