Define scrolling at the bottom of the page in a WebBrowser control

I am working on scrolling a web browser control in a VB.NET application and was able, slowly, in code, to scroll to the end of the document using a timer. I would like to know if there is a way to say when I scroll the bottom so that I can go back to start all over again.

I tried to check the height of the document, but this is only the height of my screen. Is there a property that I can check to determine if I am below to scroll?

I am currently scrolling the page at the bottom of the page:

 Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        Timer2.Enabled = True
    End Sub

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        scrollPos = scrollPos + 50
        WebBrowser1.Document.Window.ScrollTo(0, scrollPos)
    End Sub
+4
source share
1 answer

Try it if this solves your problem.

Private Function IsBottom() As Boolean
    'return True if scroll reached body bottom, else False
    Return (scrollPos >= WebBrowser1.Document.Body.ScrollRectangle.Height)
End Function
+3
source

All Articles