Udostępnij za pośrednictwem


Porady: ustawianie tła panelu formularzy systemu Windows

Kontrolka Formularze systemu Panel Windows może wyświetlać zarówno kolor tła, jak i obraz tła. Właściwość BackColor ustawia kolor tła dla zawartych kontrolek, takich jak etykiety i przyciski radiowe. Jeśli właściwość nie jest ustawiona BackgroundImage , BackColor zaznaczenie wypełni cały panel. Jeśli właściwość jest ustawiona BackgroundImage , obraz będzie wyświetlany za zawartymi kontrolkami.

Aby programowo ustawić tło

  1. Ustaw właściwość panelu BackColor na wartość typu System.Drawing.Color.

    Panel1.BackColor = Color.AliceBlue  
    
    panel1.BackColor = Color.AliceBlue;  
    
    panel1->BackColor = Color::AliceBlue;  
    
  2. Ustaw właściwość panelu BackgroundImage przy użyciu FromFile metody System.Drawing.Image klasy .

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

Zobacz też