Label.Image 속성

정의

Label에 표시되는 이미지를 가져오거나 설정합니다.

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에 표시되는 Label입니다. 기본값은 null입니다.

예제

다음 코드 예제를 만드는 방법을 보여 줍니다.는 Label 뒤에 표시 ImageLabel하는 합니다. 먼저 이 예제에서는 을 Label 만든 다음 디스크 파일을 기반으로 을 만듭니다 Image . 다음으로, 속성이 Size 를 포함 Image하도록 초기화됩니다. 마지막으로 속성이 Image 로 초기화됩니다 Image.

public:
   void CreateMyLabel()
   {
      // Create a new label and create a bitmap.
      Label^ label1 = gcnew Label;
      Image^ image1 = Image::FromFile( "c:\\MyImage.bmp" );

      // Set the size of the label to accommodate the bitmap size.
      label1->Size = System::Drawing::Size( image1->Width, image1->Height );

      // Initialize the label control's Image property.
      label1->Image = image1;

      // ...Code to add the control to the form...
   }
public void CreateMyLabel() 
{
 
    // Create a new label and create a bitmap.

    Label label1 = new Label();
    Image image1 = Image.FromFile("c:\\MyImage.bmp");

    // Set the size of the label to accommodate the bitmap size.

    label1.Size = new Size(image1.Width, image1.Height);

    // Initialize the label control's Image property.

    label1.Image = image1;

    // ...Code to add the control to the form...
}
Private Sub CreateMyLabel()

    ' Create a new label and bitmap.

    Dim Label1 As New Label()
    Dim Image1 As Image

    Image1 = Image.FromFile("c:\\MyImage.bmp")
   

    ' Set the size of the label to accommodate the bitmap size.

    Label1.Size = Image1.Size        

    ' Initialize the label control's Image property.

    Label1.Image = Image1

    ' ...Code to add the control to the form...

End Sub

설명

속성은 Image 및 속성과 ImageIndex 동시에 ImageList 사용할 수 없습니다. Image 속성을 사용하여 이미지를 ImageList 표시하면 및 ImageIndex 속성이 자동으로 기본 설정으로 설정됩니다.

적용 대상

추가 정보