ButtonBase.Image 속성

정의

단추 컨트롤에 표시되는 이미지를 가져오거나 설정합니다.

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

속성 값

단추 컨트롤에 표시되는 Image입니다. 기본값은 null입니다.

예제

다음 코드 예제에서는 파생 클래스 Button 를 사용 하 고 해당 공용 속성 중 일부를 설정 합니다. 결과는 왼쪽에 텍스트가 있고 오른쪽에 이미지가 있는 플랫 단추가 됩니다. 이 코드를 사용하려면 디렉터리에 저장된 C:\Graphics 라는 MyBitMap.bmp 비트맵 이미지가 있어야 하며 네임스페이스에 대한 참조 System.Drawing 가 포함되어야 합니다.

private:
   void SetMyButtonProperties()
   {
      // Assign an image to the button.
      button1->Image = Image::FromFile( "C:\\Graphics\\MyBitmap.bmp" );
      // Align the image and text on the button.
      button1->ImageAlign = ContentAlignment::MiddleRight;
      button1->TextAlign = ContentAlignment::MiddleLeft;
      // Give the button a flat appearance.
      button1->FlatStyle = FlatStyle::Flat;
   }
private void SetMyButtonProperties()
 {
    // Assign an image to the button.
    button1.Image = Image.FromFile("C:\\Graphics\\MyBitmap.bmp");
    // Align the image and text on the button.
    button1.ImageAlign = ContentAlignment.MiddleRight;    
    button1.TextAlign = ContentAlignment.MiddleLeft;
    // Give the button a flat appearance.
    button1.FlatStyle = FlatStyle.Flat;
 }
Private Sub SetMyButtonProperties()
    ' Assign an image to the button.
    button1.Image = Image.FromFile("C:\Graphics\MyBitmap.bmp")
    ' Align the image and text on the button.
    button1.ImageAlign = ContentAlignment.MiddleRight
    button1.TextAlign = ContentAlignment.MiddleLeft
    ' Give the button a flat appearance.
    button1.FlatStyle = FlatStyle.Flat
End Sub

설명

속성이 Image 설정되면 속성이 ImageListnull설정되고 속성이 ImageIndex 기본값인 -1로 설정됩니다.

참고

속성이 로 FlatStyle 설정된 FlatStyle.System경우 속성에 Image 할당된 모든 이미지가 표시되지 않습니다.

적용 대상

추가 정보