Results 1 to 8 of 8

Thread: HELP Progress bar

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2009
    Posts
    150

    Resolved HELP Progress bar

    hi im a newbie i use visual studio 2008 i have a problem i finally got the progress bar to work but i want it to stop when the website i choose to display is fully loaded can anyone help me here is my code below
    Public Class Form1

    Code:
     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            WebBrowser1.Navigate(TextBox1.Text)
        End Sub
    
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            WebBrowser1.GoBack()
        End Sub
        Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
            WebBrowser1.GoForward()
        End Sub
        Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
            WebBrowser1.Refresh()
    
        End Sub
    
        Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
            WebBrowser1.Stop()
    
        End Sub
        Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
            WebBrowser1.GoHome()
    
        End Sub
        Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.MouseClick
            PrintDialog1.ShowDialog()
    
    
        End Sub
        Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
    
        End Sub
        Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
            If e.KeyCode = Keys.Enter Then Button1.PerformClick()
    
        End Sub
    
        Private Sub ProgressBar1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
            ProgressBar1.Increment(1)
            If Timer1.Enabled = True Then
                ProgressBar1.Value = 0
            End If
            If Timer2.Enabled = True Then
                ProgressBar1.Value = 100
    
            End If
        End Sub
    
    
    
        Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
    
        End Sub
    
    End Class
    Last edited by pillhead2007; Jul 17th, 2009 at 05:36 PM.

  2. #2
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: HELP Progress bar

    If you double click your webbrowser control in the designer it will create and take you to the DocumentCompleted event handler. This event is fired each time the browser control finishes loading a page, so simply stick the code in here that stops your progress bar (ie progressbar1.Value = 0 or whatever)
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  3. #3
    Frenzied Member stateofidleness's Avatar
    Join Date
    Jan 2009
    Posts
    1,780

    Re: HELP Progress bar

    Told you in the other thread. In the webbrowser's DownloadComplete event, do what you need to do to the progress bar, most likely setting its value to 0

  4. #4
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: HELP Progress bar

    Quote Originally Posted by stateofidleness View Post
    Told you in the other thread. In the webbrowser's DownloadComplete event, do what you need to do to the progress bar, most likely setting its value to 0
    Its DocumentCompleted not DownloadComplete
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2009
    Posts
    150

    Re: HELP Progress bar

    thank you so much chris and ste offidleness if you did say that coz i probely didnt completely understand what you meant sorri thanks chris

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jul 2009
    Posts
    150

    Re: HELP Progress bar

    it has worked but how do i get the progress bar to work with the refresh button mate if you know how to as i say im a total newbie at this

  7. #7
    Frenzied Member stateofidleness's Avatar
    Join Date
    Jan 2009
    Posts
    1,780

    Re: HELP Progress bar

    the DocumentComplete event won't take into consideration pages with frames. It will fire after each frame is loaded. the DownloadComplete event will only fire once, once the entire page (all frames) are completely loaded. Thus, giving a better status indicator of when the page is "loaded."

    refreshing should produce the same result. if you set progressbar's value back to 0 after each load, then on the next load it will start at 0 and be set to full again in the DownloadComplete event.

  8. #8
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: HELP Progress bar

    There is no DownloadComplete event on the .NET Webbrowser control as far as I can see...
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width