Como: Definir o plano de fundo de um painel de formulários do Windows

Windows Forms Panel controle pode exibir uma cor de plano de fundo e uma imagem de plano de fundo. O BackColor propriedade define a cor de fundo para os controles contidos, como rótulos e botões de rádio. Se a BackgroundImage não for definida, a BackColor seleção preencherá o painel inteiro. Se o BackgroundImage for definida, a imagem será exibida atrás controles contidos.

Para definir o plano de fundo programaticamente

  1. Definir o painel BackColor propriedade para um valor do tipo System.Drawing.Color.

    Panel1.BackColor = Color.AliceBlue
    
    panel1.BackColor = Color.AliceBlue;
    
    panel1->BackColor = Color::AliceBlue;
    
  2. Definir o painel BackgroundImage de propriedade usando o FromFile método da System.Drawing.Image classe.

    ' 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"));
    

Consulte também

Referência

Visão geral do controle de painel (Windows Forms)

BackColor

BackgroundImage

Outros recursos

Painel de controle (Windows Forms)