Label.Image Property

Definition

Label에 표시되는 이미지를 가져오거나 설정합니다.Gets or sets the image that is displayed on a Label.

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

Property Value

Image

Image에 표시되는 Label입니다.An Image displayed on the Label. 기본값은 null입니다.The default is null.

Examples

다음 코드 예제에서는 Label 만든 다음 Label뒤에 Image를 표시 하는 방법을 보여 줍니다.The following code example demonstrates how to create a Label and then to display an Image behind the Label. 첫째,이 예제에서는 Label 만든 다음 디스크 파일을 기반으로 Image을 만듭니다.First, the example creates a Label and then creates an Image based on a disk file. 그런 다음 Size 속성이 Image를 포함 하도록 초기화 됩니다.Next, the Size property is initialized to contain the Image. 마지막으로 Image 속성은 Image으로 초기화 됩니다.Finally, the Image property is initialized to the 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

Remarks

Image 속성은 ImageListImageIndex 속성과 동시에 사용할 수 없습니다.The Image property cannot be used at the same time as the ImageList and ImageIndex properties. Image 속성을 사용 하 여 이미지를 표시 하는 경우 ImageListImageIndex 속성은 자동으로 기본 설정으로 설정 됩니다.When the Image property is used to display an image, the ImageList and ImageIndex properties are automatically set to their default settings.

Applies to

See also