语言

ImageList.ImageCollection.AddStrip(Image) 方法

定义

将指定图像的图像条带添加到 .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

参数

value
Image

包含要添加的图像的 A Bitmap 。

返回

新添加的图像的索引,或者如果无法添加映像,则 -1。

例外

正在添加的图像为 null.

-或-

正在添加的图像不是 .Bitmap

无法添加映像。

-或-

要添加的图像条带的宽度为 0,或者宽度不等于现有图像宽度。

-或-

图像条带高度不等于现有图像高度。

示例

以下示例演示如何使用 AddStrip。 若要运行此示例,请将以下代码粘贴到包含名为 ImageList 的 imageList1 的 Windows 窗体中,并在处理按钮的 AddStripToCollection 事件时调用此示例中的 Click 方法。

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

注解

要添加的图像数根据给定图像的宽度推断。

条带是一个图像,被视为并排排列的多个图像。

适用于