다음을 통해 공유


방법: Windows Forms 패널의 배경 설정

Windows Forms Panel 컨트롤은 배경색과 배경 이미지를 모두 표시할 수 있습니다. BackColor 속성은 레이블 및 라디오 단추와 같은 포함된 컨트롤의 배경색을 설정합니다. BackgroundImage 속성이 설정되지 않은 경우 BackColor 선택 영역이 전체 패널을 채웁니다. BackgroundImage 속성이 설정되면 포함된 컨트롤 뒤에 이미지가 표시됩니다.

프로그래밍 방식으로 배경을 설정하려면

  1. 패널의 BackColor 속성을 형식 System.Drawing.Color 값으로 설정합니다.

    Panel1.BackColor = Color.AliceBlue  
    
    panel1.BackColor = Color.AliceBlue;  
    
    panel1->BackColor = Color::AliceBlue;  
    
  2. System.Drawing.Image 클래스의 FromFile 메서드를 사용하여 패널의 BackgroundImage 속성을 설정합니다.

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

참고 항목