다음을 통해 공유


Control.BackgroundImage 속성

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

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
<LocalizableAttribute(True)> _
Public Overridable Property BackgroundImage As Image
‘사용 방법
Dim instance As Control
Dim value As Image

value = instance.BackgroundImage

instance.BackgroundImage = value
[LocalizableAttribute(true)] 
public virtual Image BackgroundImage { get; set; }
[LocalizableAttribute(true)] 
public:
virtual property Image^ BackgroundImage {
    Image^ get ();
    void set (Image^ value);
}
/** @property */
public Image get_BackgroundImage ()

/** @property */
public void set_BackgroundImage (Image value)
public function get BackgroundImage () : Image

public function set BackgroundImage (value : Image)

속성 값

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

설명

  • 컨트롤에 그래픽 이미지를 삽입하려면 BackgroundImage 속성을 사용합니다.

참고

Windows Forms 컨트롤은 반투명색 또는 투명색 이미지를 배경 이미지로 지원하지 않습니다.

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

상속자 참고 사항 파생 클래스에서 BackgroundImage 속성을 재정의하는 경우 기본 클래스의 BackgroundImage 속성을 사용하여 기본 구현을 확장합니다. 그렇지 않으면 모든 구현을 제공해야 합니다. BackgroundImage 속성의 getset 접근자를 모두 재정의할 필요는 없습니다. 필요에 따라 하나의 접근자만 재정의하면 됩니다.

예제

다음 코드 예제에서는 Button을 폼에 추가하고 해당 공용 속성 중 일부를 설정합니다. 예제에서는 폼의 오른쪽 아래 모퉁이에 단추를 고정시켜 폼의 크기가 조정될 경우 상대적인 위치를 유지할 수 있도록 합니다. 다음에는 BackgroundImage를 설정하고 Image와 같은 크기로 단추의 크기를 조정합니다. 그런 다음 TabStoptrue로 설정하고 TabIndex 속성을 설정합니다. 마지막으로 단추의 Click 이벤트를 처리하는 이벤트 처리기를 추가합니다. 이 예제를 실행하려면 imageList1이라는 ImageList가 있어야 합니다.

' 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
// 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:
   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.set_Anchor(AnchorStyles.Bottom | AnchorStyles.Right);
    // Assign a background image.
    button1.set_BackgroundImage(imageList1.get_Images().get_Item(0));
    // Specify the layout style of the background image. Tile is the 
    // default.
    button1.set_BackgroundImageLayout(ImageLayout.Center);
    // Make the button the same size as the image.
    button1.set_Size(button1.get_BackgroundImage().get_Size());
    // Set the button's TabIndex and TabStop properties.
    button1.set_TabIndex(1);
    button1.set_TabStop(true);
    // Add a delegate to handle the Click event.
    button1.add_Click(new System.EventHandler(this.button1_Click));
    // Add the button to the form.
    this.get_Controls().Add(button1);
} //AddMyButton

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

참고 항목

참조

Control 클래스
Control 멤버
System.Windows.Forms 네임스페이스
Image
BackgroundImageChanged
BackgroundImageLayout
BackgroundImageLayoutChanged
OnBackgroundImageChanged
OnBackgroundImageLayoutChanged