다음을 통해 공유


Label.ImageList 속성

Label 컨트롤에 표시할 이미지를 포함하는 ImageList를 가져오거나 설정합니다.

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

구문

‘선언
Public Property ImageList As ImageList
‘사용 방법
Dim instance As Label
Dim value As ImageList

value = instance.ImageList

instance.ImageList = value
public ImageList ImageList { get; set; }
public:
property ImageList^ ImageList {
    ImageList^ get ();
    void set (ImageList^ value);
}
/** @property */
public ImageList get_ImageList ()

/** @property */
public void set_ImageList (ImageList value)
public function get ImageList () : ImageList

public function set ImageList (value : ImageList)

속성 값

Image 개체의 컬렉션을 저장하는 ImageList입니다. 기본값은 Null 참조(Visual Basic의 경우 Nothing)입니다.

설명

ImageIndexImageList 속성은 Image 속성과 동시에 사용할 수 없습니다. ImageIndex 속성과 ImageList 속성을 사용하여 이미지를 표시하면 Image 속성이 Null 참조(Visual Basic의 경우 Nothing)로 설정됩니다.

참고

ImageList가 다른 곳에서 계속 참조되고 있으면 Label은 가비지 수집되지 않습니다. 효율적으로 가비지를 수집하려면 LabelImageList 속성을 Null 참조(Visual Basic의 경우 Nothing)로 설정하십시오.

예제

다음 코드 예제에서는 ImageListImageIndex 속성으로 표시되는 3차원 테두리 및 이미지가 있는 Label 컨트롤을 만드는 방법을 보여 줍니다. 또한 이 컨트롤에는 지정된 니모닉 문자를 사용하는 캡션이 있습니다. 이 예제 코드에서는 PreferredHeightPreferredWidth 속성을 사용하여 Label 컨트롤이 표시된 폼 위에서 해당 컨트롤의 크기를 적절히 조정합니다. 이 예제를 실행하려면 imageList1이라는 이름으로 ImageList가 만들어져 있고 여기에 두 개의 이미지가 로드되어 있어야 합니다. 또한 이 예제를 실행하려면 해당 코드에 System.Drawing 네임스페이스가 추가된 폼 안에 코드가 있어야 합니다.

Public Sub CreateMyLabel()
    ' Create an instance of a Label.
    Dim label1 As New Label()
       
    ' Set the border to a three-dimensional border.
    label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
    ' Set the ImageList to use for displaying an image.
    label1.ImageList = imageList1
    ' Use the second image in imageList1.
    label1.ImageIndex = 1
    ' Align the image to the top left corner.
    label1.ImageAlign = ContentAlignment.TopLeft
     
    ' Specify that the text can display mnemonic characters.
    label1.UseMnemonic = True
    ' Set the text of the control and specify a mnemonic character.
    label1.Text = "First &Name:"
       
    ' Set the size of the control based on the PreferredHeight and PreferredWidth values. 
    label1.Size = New Size(label1.PreferredWidth, label1.PreferredHeight)

    '...Code to add the control to the form...
End Sub
public void CreateMyLabel()
{
   // Create an instance of a Label.
   Label label1 = new Label();

   // Set the border to a three-dimensional border.
   label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
   // Set the ImageList to use for displaying an image.
   label1.ImageList = imageList1;
   // Use the second image in imageList1.
   label1.ImageIndex = 1;
   // Align the image to the top left corner.
   label1.ImageAlign = ContentAlignment.TopLeft;

   // Specify that the text can display mnemonic characters.
   label1.UseMnemonic = true;
   // Set the text of the control and specify a mnemonic character.
   label1.Text = "First &Name:";
   
   /* Set the size of the control based on the PreferredHeight and PreferredWidth values. */
   label1.Size = new Size (label1.PreferredWidth, label1.PreferredHeight);

   //...Code to add the control to the form...
}
public:
   void CreateMyLabel()
   {
      // Create an instance of a Label.
      Label^ label1 = gcnew Label;
      
      // Set the border to a three-dimensional border.
      label1->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
      // Set the ImageList to use for displaying an image.
      label1->ImageList = imageList1;
      // Use the second image in imageList1.
      label1->ImageIndex = 1;
      // Align the image to the top left corner.
      label1->ImageAlign = ContentAlignment::TopLeft;
      
      // Specify that the text can display mnemonic characters.
      label1->UseMnemonic = true;
      // Set the text of the control and specify a mnemonic character.
      label1->Text = "First &Name:";
      
      /* Set the size of the control based on the PreferredHeight and PreferredWidth values. */
      label1->Size = System::Drawing::Size( label1->PreferredWidth, label1->PreferredHeight );
      
      //...Code to add the control to the form...
   }
public void CreateMyLabel()
{
    // Create an instance of a Label.
    Label label1 = new Label();
    // Set the border to a three-dimensional border.
    label1.set_BorderStyle(System.Windows.Forms.BorderStyle.Fixed3D);
    // Set the ImageList to use for displaying an image.
    label1.set_ImageList(imageList1);
    // Use the second image in imageList1.
    label1.set_ImageIndex(1);
    // Align the image to the top left corner.
    label1.set_ImageAlign(ContentAlignment.TopLeft);
    // Specify that the text can display mnemonic characters.
    label1.set_UseMnemonic(true);
    // Set the text of the control and specify a mnemonic character.
    label1.set_Text("First &Name:");
    /* Set the size of the control based on the PreferredHeight
       and PreferredWidth values. */
    label1.set_Size(new Size(label1.get_PreferredWidth(), 
        label1.get_PreferredHeight()));
    //...Code to add the control to the form...
} //CreateMyLabel 
public function CreateMyLabel()
{
   // Create an instance of a Label.
   var label1 : Label = new Label();

   // Set the border to a three-dimensional border.
   label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
   // Set the ImageList to use for displaying an image.
   label1.ImageList = imageList1;
   // Use the second image in imageList1.
   label1.ImageIndex = 1;
   // Align the image to the top left corner.
   label1.ImageAlign = ContentAlignment.TopLeft;

   // Specify that the text can display mnemonic characters.
   label1.UseMnemonic = true;
   // Set the text of the control and specify a mnemonic character.
   label1.Text = "First &Name:";
   
   /* Set the size of the control based on the PreferredHeight and PreferredWidth values. */
   label1.Size = new System.Drawing.Size (label1.PreferredWidth, label1.PreferredHeight);

   //...Code to add the control to the form...
}

플랫폼

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에서 지원

참고 항목

참조

Label 클래스
Label 멤버
System.Windows.Forms 네임스페이스
Label.Image 속성
Label.ImageAlign 속성
Label.ImageIndex 속성
ImageList 클래스