ButtonBase.ImageList 속성

정의

단추 컨트롤에 표시된 ImageList를 포함하는 Image를 가져오거나 설정합니다.

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

속성 값

ImageList

ImageList입니다. 기본값은 null입니다.

예제

다음 코드 예제에서는 파생된 클래스 Button 를 사용 하 고 및 ImageIndex 속성을 설정 ImageList 합니다. 이 코드를 사용하려면 ImageList 만든 코드가 하나 Image 이상 할당되어 있어야 합니다. 또한 이 코드를 사용하려면 디렉터리에 저장된 C:\Graphics 비트 MyBitMap.bmp 맵 이미지가 있어야 합니다.

private:
   void AddMyImage()
   {
      // Assign an image to the imageList.
      imageList1->Images->Add( Image::FromFile( "C:\\Graphics\\MyBitmap.bmp" ) );
      // Assign the imageList to the button control.
      button1->ImageList = imageList1;
      // Select the image from the ImageList (using the ImageIndex property).
      button1->ImageIndex = 0;
   }
private void AddMyImage()
 {
    // Assign an image to the ImageList.
    ImageList1.Images.Add(Image.FromFile("C:\\Graphics\\MyBitmap.bmp"));
    // Assign the ImageList to the button control.   
    button1.ImageList = ImageList1;
    // Select the image from the ImageList (using the ImageIndex property).    
    button1.ImageIndex = 0;
 }
Private Sub AddMyImage()
    ' Assign an image to the ImageList.
    ImageList1.Images.Add(Image.FromFile("C:\Graphics\MyBitmap.bmp"))
    ' Assign the ImageList to the button control.   
    button1.ImageList = ImageList1
    ' Select the image from the ImageList (using the ImageIndex property).    
    button1.ImageIndex = 0
End Sub

설명

ImageList 또는 ImageIndex 속성이 설정 Image 되면 기본값인 속성이 설정null됩니다.

참고

속성 값이 ImageList 변경 null된 경우 속성은 ImageIndex 기본값 -1을 반환합니다. 그러나 할당된 ImageIndex 값은 내부적으로 유지되며 다른 ImageList 값이 속성에 ImageList 할당될 때 사용됩니다. 속성에 ImageList 할당된 새 ImageList 속성 값이 속성 ImageList.ImageCollection.Count 에 할당된 ImageIndex 값에서 1을 뺀 값보다 작거나 같은 경우(컬렉션이 0부터 시작하는 인덱스이므로) ImageIndex 속성 값이 속성 값보다 Count 작은 값으로 조정됩니다. 예를 들어 세 개의 이미지가 있고 ImageIndex 속성이 ImageList 2로 설정된 단추 컨트롤을 생각해 보세요. 단추에 두 개의 이미지만 있는 새 ImageList 이미지가 할당되면 값이 ImageIndex 1로 변경됩니다.

적용 대상

추가 정보