Webbrowser Progress Bar

I have a Webbrowser and I am trying to create a Progress bar.

Page 1 of 1

3 Replies - 14354 Views - Last Post: 08 February 2010 - 11:19 PM Rate Topic: ***-- 2 Votes

Poll: Webbrowser Project (8 member(s) have cast votes)

Did you create a Webbrowser as a First Project in VB.NET

  1. Yes (4 votes [50.00%] - View)

    Percentage of vote: 50.00%

  2. Voted No (4 votes [50.00%] - View)

    Percentage of vote: 50.00%

Vote Guests cannot vote

#1 krismania  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 18
  • View blog
  • Posts: 148
  • Joined: 03-January 10

Webbrowser Progress Bar

Posted 07 February 2010 - 11:49 PM

I have been trying to create a Progress bar for my webbrowser controll that shows how far the page is in loading. I want it to start empty when a link is clicked, fill up as the page loads then stay full when the page finishes loading. I cant get it to stay filled though. Here is the code I have so far:
    Private Sub WebBrowser1_ProgressChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles WebBrowser1.ProgressChanged
        Try
            ProgressBar1.Maximum = e.MaximumProgress
            ProgressBar1.Value = e.CurrentProgress
            Label1.Text = "Loading"

            If ProgressBar1.Value = ProgressBar1.Maximum Then

                Label1.Text = "Done"
                ProgressBar1.Value = ProgressBar1.Maximum

            End If
        Catch ex As Exception
            Label1.Text = "Error Loading"
        End Try
    End Sub


The label is also next to the progress bar and It needs to say what the the browser is doing. eg Loading, Done, ect... thanks for your help :D

Is This A Good Question/Topic? 0
  • +

Replies To: Webbrowser Progress Bar

#2 Luc001  Icon User is offline

  • D.I.C Addict

Reputation: 84
  • View blog
  • Posts: 617
  • Joined: 04-May 09

Re: Webbrowser Progress Bar

Posted 08 February 2010 - 10:08 AM

Hi,

I think you can try this for your Progressbar.
Put it into the progresschanged event

If e.MaximumProgress <> 0 And e.MaximumProgress >= e.CurrentProgress Then
            ProgressBar1.Value = Convert.ToInt32(100 * e.CurrentProgress / e.MaximumProgress)

        Else
            With ProgressBar1
                .Value = 100
                .Visible = True
            End With
        End If

This post has been edited by Luc001: 08 February 2010 - 10:09 AM

Was This Post Helpful? 0
  • +
  • -

#3 Jack Eagles1  Icon User is offline

  • Pugnacious Penguin (inspired by no2pencil)
  • member icon

Reputation: 183
  • View blog
  • Posts: 1,152
  • Joined: 10-December 08

Re: Webbrowser Progress Bar

Posted 08 February 2010 - 10:20 AM

Try having a look at the DocumentCompleted event in the webbrowser, and setting the progressbar to maximum when the event is fired.
Was This Post Helpful? 0
  • +
  • -

#4 krismania  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 18
  • View blog
  • Posts: 148
  • Joined: 03-January 10

Re: Webbrowser Progress Bar

Posted 08 February 2010 - 11:19 PM

@Luc001
your code works fine so I will go with that for now. Thanks :bigsmile:

@Jack Eagles1
If I set it to max then it won't move when a new page loads. thanks for helping anyways :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1