Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
AddStrip Method

ImageList.ImageCollection.AddStrip Method

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

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public int AddStrip(
	Image value
)

Parameters

value
Type: System.Drawing.Image

A Bitmap with the images to add.

Return Value

Type: System.Int32
The index of the newly added image, or -1 if the image cannot be added.

ExceptionCondition
ArgumentException

The image being added is null.

-or-

The image being added is not a Bitmap.

InvalidOperationException

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.

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.

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);

    }


}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft