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 具有要加入的影像。

傳回

新加入影像的索引,如果無法加入影像,則為 -1。

例外狀況

要加入的影像是 null

-或-

要加入的影像不是 Bitmap

無法加入影像。

-或-

要加入的影像區域寬度是 0,或寬度不等於現有的影像寬度。

-或-

影像區域的高度不等於現有的影像高度。

範例

下列範例示範如何使用 AddStrip 。 若要執行此範例,請將下列程式碼貼到包含 ImageList 具名 imageList1 和按鈕的 Windows Form 中,並在處理按鈕 Click 的 事件時呼叫 AddStripToCollection 這個範例中的 方法。

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

備註

要新增的影像數目是從指定影像的寬度推斷而來。

帶狀區是視為並排排列的多個影像的單一影像。

適用於