Imports System.ComponentModel Public Class Form3 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Me.PictureBox1.ImageLocation = "http://kemilia.ninja-web.net/free/yama1-1024.jpg" Me.PictureBox1.CancelAsync() End Sub Private Sub PictureBox1_LoadCompleted(sender As Object, e As AsyncCompletedEventArgs) Handles PictureBox1.LoadCompleted If e.Error IsNot Nothing Then MsgBox("読み込み時にエラーが発生しました。") ElseIf e.Cancelled Then MsgBox("キャンセルボタンが押されました。") Else MsgBox("読み込みが終わりました。") End If End Sub End Class
> The LoadCompleted occurs only when the image is loaded asynchronously by using one of the LoadAsync methods, and WaitOnLoad is false. > If the image-load is canceled by calling the CancelAsync method the Cancelled property of the AsyncCompletedEventArgs will be set to true.
Private Sub Form3_Load(sender As Object, e As EventArgs) Handles Me.Load Me.PictureBox1.WaitOnLoad = False End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Me.PictureBox1.LoadAsync("http://kemilia.ninja-web.net/free/yama1-1024.jpg") Me.PictureBox1.CancelAsync() End Sub Private Sub PictureBox1_LoadCompleted(sender As Object, e As AsyncCompletedEventArgs) Handles PictureBox1.LoadCompleted If e.Error IsNot Nothing Then MsgBox("読み込み時にエラーが発生しました。") ElseIf e.Cancelled Then MsgBox("キャンセルボタンが押されました。") Else MsgBox("読み込みが終わりました。") End If End Sub