PictureBox.WaitOnLoad 屬性

定義

取得或設定值,指出是否同步載入影像。

public:
 property bool WaitOnLoad { bool get(); void set(bool value); };
public bool WaitOnLoad { get; set; }
member this.WaitOnLoad : bool with get, set
Public Property WaitOnLoad As Boolean

屬性值

如果同步完成影像載入作業則為 true,否則為 false。 預設為 false

範例

下列程式碼範例示範如何使用 WaitOnLoad 屬性。 若要執行此範例,請將下列程式碼貼到 Windows Form 中,其中包含 PictureBox 名為 pictureBox1 的 和 Button 名為 startLoadButton 的 。 請確定 Click 按鈕的事件與此範例中的 方法相關聯 startLoadButton_Click 。 您必須將映射檔路徑變更為系統上有效的映射檔路徑。

private void startButton_Click(object sender, EventArgs e)
{
    // Ensure WaitOnLoad is false.
    pictureBox1.WaitOnLoad = false;

    // Load the image asynchronously.
    pictureBox1.LoadAsync(@"http://localhost/print.gif");
}
Private Sub startLoadButton_Click(ByVal sender As Object, _
    ByVal e As EventArgs) Handles startLoadButton.Click

    ' Ensure WaitOnLoad is false.
    pictureBox1.WaitOnLoad = False

    ' Load the image asynchronously.
    pictureBox1.LoadAsync("http://localhost/print.gif")

End Sub

備註

WaitOnLoad將 屬性設定為 true 表示影像會以同步方式載入。 這會導致使用者介面遭到封鎖,直到載入影像為止。 falseWaitOnLoad (預設) ,並使用 LoadAsync 方法來載入影像時, InitialImage 會在載入指定的影像時顯示影像,而且使用者可以在載入過程中與介面互動。

適用於