I have not tried to attach a network image when I used picturebox of winform. Code The loadasync method can be used to load images asynchronously, And the loadprogresschanged event can be used to get the current loading progress.
Put a picturebox control, a button, a progress bar control on the form, and use a label to display the current progress percentage. The Code is as follows:
Private Void Button#click ( Object Sender, eventargs E)
{
Try
{
Picturebox1.waitonload = False ;
Picturebox1.loadasync (
" Http://hiphotos.baidu.com/18826860/pic/item/c68220d54518d3ef562c841c.jpg " );
}
Catch
{
MessageBox. Show ( " Network Connection Failed " );
}
}
Add the loadprogresschanged event to picturebox, And the loadasync method will trigger this event. The current progress can be obtained from E. progresspercentage.
Private VoidPicturebox1_loadprogresschanged (Object
Sender, system. componentmodel. progresschangedeventargs
E)
{
Progressbar1.value = E. progresspercentage;
Label1.text =
E. progresspercentage. tostring () +"%";
}