Aracılığıyla paylaş


ButtonBase.ImageList Özellik

Tanım

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. Varsayılan değer null değeridir.

Ö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 en az bir tane Image atanmış olmasını gerektirir. Bu kod ayrıca dizininde C:\Graphics depolanan adlı MyBitMap.bmp bir bit eşlem görüntüye sahip olmanız gerekir.

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.

Uyarı

ImageList Özellik değeri olarak nullImageIndex değiştirilirse, özellik varsayılan değeri olan -1 değerini döndürür. Ancak, atanan ImageIndex değer dahili olarak tutulur ve başka bir ImageList özellik atandığında ImageList kullanılır. Özelliğe atanan yeni ImageList özelliğinImageList, özelliğe atanan ImageIndex değerden 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 bir küçük değere ayarlanır. Örneğin, üç görüntüsü olan ImageList ve ImageIndex özelliği 2 olarak ayarlanmış bir düğme denetimi 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.