Nasıl yapılır: Windows Forms Panelinin Arka Planını Ayarlama

Windows Forms Panel denetimi hem arka plan rengini hem de arka plan görüntüsünü görüntüler. özelliği, BackColor etiketler ve radyo düğmeleri gibi, içerdiği denetimlerin arka plan rengini ayarlar. Özellik BackgroundImage ayarlanmazsa seçim BackColor panelin tamamını kaplar. Özelliği BackgroundImage ayarlanırsa görüntü, içerdiği denetimlerin arkasında görüntülenir.

Arka planı program aracılığıyla ayarlamak için

  1. Panelin özelliğini BackColor türünde bir değere System.Drawing.Color ayarlayın.

    Panel1.BackColor = Color.AliceBlue  
    
    panel1.BackColor = Color.AliceBlue;  
    
    panel1->BackColor = Color::AliceBlue;  
    
  2. sınıfının yöntemini kullanarak BackgroundImage panelin FromFile özelliğini System.Drawing.Image ayarlayın.

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

Ayrıca bkz.