Using a Progress Bar

computermat

Active member
Joined
Jun 17, 2007
Messages
28
Programming Experience
Beginner
hi, I am developing an application with a built in web browser and would like to add a progress bar and status label to show web page download progress.

I want to have it so my progress bar updates as pages download and have a label that says downloading site / done, like what you get in firefox, IE etc.

Is there an easy way of implementing this is vb.

Regards
Matt
 
Add the ProgressBar (ToolStripProgressBar) to the StatusStrip, use the ProgressChanged event of WebBrowsercontrol to update it, you calculate current progress percentage from e.CurrentProgress and e.MaximumProgress (both change continuously) and set this as the Value of progress.
 
hi, thanks for the quick reply. I have got the progress bar working with the following code which does not implement maxprogress only current.

VB.NET:
    Private Sub WebBrowser2_ProgressChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles WebBrowser2.ProgressChanged
        prgStatus.ProgressBar.Value = e.CurrentProgress.ToString()

    End Sub

Only way it would work, as i said in my first post i would like a label to write the status of the browser, so it can say downloading / done. I have got it to declare when pages have downloaded with the document completed declaration. However, i cannot get the downloading status to work. I am using the following code
VB.NET:
    Private Sub WebBrowser2_Navigating(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs) Handles WebBrowser2.Navigating
        lblStatus.Text = "Downloading: " & WebBrowser2.Url.Host & WebBrowser2.Url.AbsolutePath

    End Sub

Open for any suggestions and thanks in advance
Matt
 
About the progress you have to calculate the percentage, the Value property is of type Integer and the progress is type Long so sometimes it won't fit (also you would have to constantly change the Max), the percentage is easy and always fits 0-100.

For the status text use the StatusTextChanged event and the StatusText property of the browser instance.
 
Back
Top