Label.Image 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
에 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 다음 뒤에 표시 Image 하는 방법을 보여 줍니다 Label. 먼저 이 예제에서는 디스크 파일을 만든 다음, 디스크 파일을 기반으로 만듭니다 LabelImage . 다음으로, 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
설명
속성 및 ImageImageIndex 속성과 동시에 ImageList 사용할 수 없습니다. Image 속성을 사용하여 이미지를 ImageList 표시하면 속성과 ImageIndex 속성이 자동으로 기본 설정으로 설정됩니다.