Condividi tramite


ButtonBase.ImageList Proprietà

Definizione

Ottiene o imposta l'oggetto che contiene l'oggetto ImageListImage visualizzato in un controllo pulsante.

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

Valore della proprietà

Un oggetto ImageList. Il valore predefinito è null.

Esempio

Nell'esempio di codice seguente viene utilizzata la classe Button derivata e vengono impostate le ImageList proprietà e ImageIndex . Questo codice richiede che sia stato creato un oggetto ImageList e che ne sia stato assegnato almeno uno Image . Questo codice richiede anche che sia presente un'immagine bitmap denominata MyBitMap.bmp archiviata nella C:\Graphics directory .

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

Commenti

Quando la ImageList proprietà o ImageIndex è impostata, la Image proprietà viene impostata null, ovvero il valore predefinito.

Annotazioni

Se il valore della ImageList proprietà viene modificato in null, la proprietà restituisce il ImageIndex valore predefinito - 1. Tuttavia, il valore assegnato ImageIndex viene mantenuto internamente e usato quando un altro ImageList viene assegnato alla ImageList proprietà . Se il nuovo ImageList assegnato alla ImageList proprietà ha un ImageList.ImageCollection.Count valore della proprietà minore o uguale al valore assegnato alla ImageIndex proprietà meno uno (perché l'insieme è un indice in base zero), il ImageIndex valore della proprietà viene regolato su un valore minore del valore della Count proprietà. Si consideri, ad esempio, un controllo pulsante con ImageList tre immagini e la cui ImageIndex proprietà è impostata su 2. Se al ImageList pulsante sono assegnate solo due immagini, il ImageIndex valore diventa 1.

Si applica a

Vedi anche