ImageList.ImageCollection.AddStrip(Image) Metodo

Definizione

Aggiunge all'oggetto ImageList un elenco immagini per l'immagine specificata.

public:
 int AddStrip(System::Drawing::Image ^ value);
public int AddStrip (System.Drawing.Image value);
member this.AddStrip : System.Drawing.Image -> int
Public Function AddStrip (value As Image) As Integer

Parametri

value
Image

Oggetto Bitmap con le immagini da aggiungere.

Restituisce

Indice dell'immagine appena aggiunta oppure -1 se non è possibile aggiungere l'immagine.

Eccezioni

L'immagine da aggiungere è null.

-oppure-

L'immagine da aggiungere non è un oggetto Bitmap.

Impossibile aggiungere l'immagine.

-oppure-

La larghezza dell'elenco immagini da aggiungere è 0 oppure la larghezza non è uguale a quella dell'immagine esistente.

-oppure-

L'altezza dell'elenco immagini non è uguale all'altezza dell'immagine esistente.

Esempio

Nell'esempio seguente viene illustrato come usare AddStrip. Per eseguire questo esempio, incollare il codice seguente in un Windows Form contenente un ImageList oggetto denominato imageList1 e un pulsante e chiamare il AddStripToCollection metodo in questo esempio quando si gestisce l'evento del Click pulsante.

public void AddStripToCollection()
{
    // Add the image strip.
    Bitmap bitmaps = new Bitmap(typeof(PrintPreviewDialog), "PrintPreviewStrip.bmp");
    imageList1.Images.AddStrip(bitmaps);
    
    // Iterate through the images and display them on the form.
    for (int i = 0; i < imageList1.Images.Count; i++) {
    
        imageList1.Draw(this.CreateGraphics(), new Point(10,10), i);
        Application.DoEvents();
        System.Threading.Thread.Sleep(1000);
    }
}
Private Sub AddStripToCollection() 
    ' Add the image strip.
    Dim bitmaps As New Bitmap(GetType(PrintPreviewDialog), "PrintPreviewStrip.bmp")
    imageList1.Images.AddStrip(bitmaps)
    
    ' Iterate through the images and display them on the form.
    For i As Integer = 0 To imageList1.Images.Count - 1
        
        imageList1.Draw(Me.CreateGraphics(), New Point(10, 10), i)
        Application.DoEvents()
        System.Threading.Thread.Sleep(1000)
    Next
 
End Sub

Commenti

Il numero di immagini da aggiungere viene dedotto dalla larghezza dell'immagine specificata.

Una striscia è una singola immagine considerata come più immagini disposte side-by-side.

Si applica a