다음을 통해 공유


방법: 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"));
    

참고 항목

참조

Panel 컨트롤 개요(Windows Forms)

BackColor

BackgroundImage

기타 리소스

Panel 컨트롤(Windows Forms)