PictureBox.LoadProgressChanged Event

Note: This event is new in the .NET Framework version 2.0.

Occurs when the progress of an asynchronous image-loading operation has changed.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public event ProgressChangedEventHandler LoadProgressChanged
/** @event */
public void add_LoadProgressChanged (ProgressChangedEventHandler value)

/** @event */
public void remove_LoadProgressChanged (ProgressChangedEventHandler value)

JScript supports the use of events, but not the declaration of new ones.

The LoadProgressChanged occurs only when the image is loaded asynchronously using one of the LoadAsync methods. The progress percentage of the image load is reported with the ProgressPercentage property of the ProgressChangedEventArgs.

Handle the LoadProgressChanged if you want to reflect the progress of an asynchronous image-loading operation in a ProgressBar or similar control. Use the ProgressPercentage property of the ProgressChangedEventArgs to update the progress value.

For more information about handling events, see Consuming Events.

The following code example demonstrates how to handle the LoadProgressChanged event. To run this example, paste the following code into a Windows Form that contains a PictureBox named pictureBox1, a Button named startLoadButton, and a ProgressBar named progressBar1. Make sure the startLoadButton_Click method is associated with the Click event for the button and the pictureBox1_LoadProgressChanged method is associated with the LoadProgressChanged event for pictureBox1. You will need to change the image file path to one that is valid on your system.

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

            // Load the image asynchronously.
...        void pictureBox1_LoadProgressChanged(object sender, 
            ProgressChangedEventArgs e)
            progressBar1.Value = e.ProgressPercentage;

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0