Control.BackgroundImage 속성

정의

컨트롤에 표시할 배경 이미지를 가져오거나 설정합니다.

public:
 virtual property System::Drawing::Image ^ BackgroundImage { System::Drawing::Image ^ get(); void set(System::Drawing::Image ^ value); };
public virtual System.Drawing.Image BackgroundImage { get; set; }
public virtual System.Drawing.Image? BackgroundImage { get; set; }
member this.BackgroundImage : System.Drawing.Image with get, set
Public Overridable Property BackgroundImage As Image

속성 값

컨트롤의 배경에 표시할 이미지를 나타내는 Image입니다.

예제

다음 코드 예제에서는 추가는 Button 폼 및 해당 공용 속성 중 일부를 설정 합니다. 이 예제에서는 폼 크기가 조정 될 때의 상대적 위치를 유지할 수 있도록 단추를 폼의 오른쪽 아래 모퉁이 고정 합니다. 설정 옆의 BackgroundImage 단추와 같은 크기를 조정 하 고는 Image합니다. 설정한 후 합니다 TabStoptrue 설정 하 고는 TabIndex 속성. 마지막으로 처리 하는 이벤트 처리기 추가 Click 단추의 이벤트입니다. 이 예제에서는 라는 imageList1ImageList 있어야 합니다.

   // Add a button to a form and set some of its common properties.
private:
   void AddMyButton()
   {
      // Create a button and add it to the form.
      Button^ button1 = gcnew Button;

      // Anchor the button to the bottom right corner of the form
      button1->Anchor = static_cast<AnchorStyles>(AnchorStyles::Bottom | AnchorStyles::Right);

      // Assign a background image.
      button1->BackgroundImage = imageList1->Images[ 0 ];

      // Specify the layout style of the background image. Tile is the default.
      button1->BackgroundImageLayout = ImageLayout::Center;

      // Make the button the same size as the image.
      button1->Size = button1->BackgroundImage->Size;

      // Set the button's TabIndex and TabStop properties.
      button1->TabIndex = 1;
      button1->TabStop = true;

      // Add a delegate to handle the Click event.
      button1->Click += gcnew System::EventHandler( this, &Form1::button1_Click );

      // Add the button to the form.
      this->Controls->Add( button1 );
   }
// Add a button to a form and set some of its common properties.
private void AddMyButton()
{
   // Create a button and add it to the form.
   Button button1 = new Button();

   // Anchor the button to the bottom right corner of the form
   button1.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right);

   // Assign a background image.
   button1.BackgroundImage = imageList1.Images[0];

   // Specify the layout style of the background image. Tile is the default.
   button1.BackgroundImageLayout = ImageLayout.Center;
   
   // Make the button the same size as the image.
   button1.Size = button1.BackgroundImage.Size;

   // Set the button's TabIndex and TabStop properties.
   button1.TabIndex = 1;
   button1.TabStop = true;

   // Add a delegate to handle the Click event.
   button1.Click += new System.EventHandler(this.button1_Click);

   // Add the button to the form.
   this.Controls.Add(button1);
}
' Add a button to a form and set some of its common properties.
Private Sub AddMyButton()
   ' Create a button and add it to the form.
   Dim button1 As New Button()
   
   ' Anchor the button to the bottom right corner of the form
   button1.Anchor = AnchorStyles.Bottom Or AnchorStyles.Right
   
   ' Assign a background image.
   button1.BackgroundImage = imageList1.Images(0)

   ' Specify the layout style of the background image. Tile is the default.
   button1.BackgroundImageLayout = ImageLayout.Center
   
   ' Make the button the same size as the image.
   button1.Size = button1.BackgroundImage.Size
   
   ' Set the button's TabIndex and TabStop properties.
   button1.TabIndex = 1
   button1.TabStop = True

   ' Add a delegate to handle the Click event.
   AddHandler button1.Click, AddressOf Me.button1_Click
   
   ' Add the button to the form.
   Me.Controls.Add(button1)
End Sub

설명

  • 사용 된 BackgroundImage 컨트롤에 그래픽 이미지를 배치 하는 속성입니다.

참고

반투명하거나 투명한 색이 있는 이미지는 Windows Forms 컨트롤에서 배경 이미지로 지원되지 않습니다.

이 속성은 속성true이 인 RightToLeftLayout 자식 컨트롤에서 지원되지 않습니다.

상속자 참고

파생 클래스에서 BackgroundImage 속성을 재정의할 때 기본 클래스의 BackgroundImage 속성을 사용하여 기본 구현을 확장합니다. 그렇지 않으면 모든 구현을 제공해야 합니다. 속성의 및 set 접근자를 모두 get 재정의할 필요는 없습니다. 필요한 경우 하나만 재정의 BackgroundImage 할 수 있습니다.

적용 대상

추가 정보