ButtonBase.ImageList Özellik

Tanım

Bir düğme denetiminde ImageList görüntülenen öğesini içeren öğesini Image alır veya ayarlar.

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

Özellik Değeri

Bir ImageList. null varsayılan değerdir.

Örnekler

Aşağıdaki kod örneği türetilmiş sınıfını Button kullanır ve ve ImageIndex özelliklerini ayarlarImageList. Bu kod, bir ImageList oluşturulmasını ve buna en az bir tane Image atanmış olmasını gerektirir. Bu kod, dizininde depolanan adlı MyBitMap.bmp bir bit eşlem görüntüsünün C:\Graphics de olmasını gerektirir.

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

Açıklamalar

ImageList veya ImageIndex özelliği ayarlandığında, Image özelliği varsayılan değeri olan olarak ayarlanırnull.

Not

ImageList Özellik değeri olarak değiştirilirsenullImageIndex, özellik varsayılan değeri olan -1 değerini döndürür. Ancak, atanan ImageIndex değer dahili olarak tutulur ve özelliğe başka ImageList bir değer atandığında ImageList kullanılır. Özelliğe atanan yeni ImageList özelliğinImageList, özelliğe atanan ImageIndex değerden eksi bir değerinden küçük veya buna eşit bir ImageList.ImageCollection.Count özellik değeri varsa (koleksiyon sıfır tabanlı bir dizin olduğundan), ImageIndex özellik değeri özellik değerinden Count küçük bir değere ayarlanır. Örneğin, üç görüntüsü olan ImageList ve ImageIndex özelliği 2 olarak ayarlanmış bir düğme denetimini düşünün. Düğmeye yalnızca iki resim içeren bir yeni ImageList atanırsa, ImageIndex değer 1 olarak değişir.

Şunlara uygulanır

Ayrıca bkz.