ImageList.ImageCollection.AddStrip(Image) Method

Definition

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

C#
public int AddStrip(System.Drawing.Image value);

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.

C#
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);
    }
}

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

Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10