Redigeeri

Jagamisviis:


ImageList.ImageCollection.AddStrip(Image) Method

Definition

Adds an image strip for the specified image to the ImageList.

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

Parameters

value
Image

A Bitmap with the images to add.

Returns

The index of the newly added image, or -1 if the image cannot be added.

Exceptions

The image being added is null.

-or-

The image being added is not a Bitmap.

The image cannot be added.

-or-

The width of image strip being added is 0, or the width is not equal to the existing image width.

-or-

The image strip height is not equal to existing image height.

Examples

The following example demonstrates how to use AddStrip. To run this example, paste the following code into a Windows Form that contains an ImageList named imageList1 and a button and call the AddStripToCollection method in this example when handling the button's Click event.

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

Remarks

The number of images to add is inferred from the width of the given image.

A strip is a single image that is treated as multiple images arranged side-by-side.

Applies to