Reputation: 43
I am working on scrolling a web browser control in a VB.NET application and was able to slowly, in code, scroll to the end of the document via a timer. What I would like to know is if there's a way to tell when I have scrolled to the bottom so that I can scroll back to the top to start things over again.
I have tried to check the height of the document, but it is only the height of my screen. Is there a property that I can check to determine if I am at the bottom for scrolling purposes?
The way I am currently scrolling to the bottom of the page is:
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
Upvotes: 4
Views: 1603
Reputation: 3678
Try if this solve your issue
Private Function IsBottom() As Boolean
'return True if scroll reached body's bottom, else False
Return (scrollPos >= WebBrowser1.Document.Body.ScrollRectangle.Height)
End Function
Upvotes: 3