語言

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

Bitmap A,附上圖片。

傳回

新新增影像的索引,或 -1 若無法新增影像。

例外狀況

新增的影像為 null。

-或-

新增的影像並非 Bitmap。

圖片無法被加入。

-或-

新增影像條的寬度為 0,或是寬度不等於現有的影像寬度。

-或-

影像條的高度與現有的影像高度不相等。

範例

下列範例示範如何使用 AddStrip。 要執行此範例,請將以下程式碼貼入包含一個名為 ImageListimageList1 及一個按鈕的 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

備註

新增圖片數量是根據給定圖片的寬度推算出來的。

條帶是一張單一影像,被視為多張並排排列的影像。

適用於