Articles in this section
Category / Section

How to scroll the scrollbar to the end of the WinForms HTMLUIControl when the HTML page is loaded?

1 min read

Scrolling

We can scroll the scrollbar to the end of the HTMLUI control using ScrollTo Rectangle() method, after loading the HTML page.

C#

private void Form1_Load(object sender, System.EventArgs e)
{
    LoadHTMLFile(@"doc.htm");
    IHTMLElement elem = this.htmluiControl1.Document.RenderRoot;
    Point lastPoint = new Point(0, (elem.Location.Y + elem.Size.Height));
    Rectangle rect = new Rectangle(new Point(10, lastPoint.Y - 10), new Size(10, 10));
    this.htmluiControl1.ScrollToRectangle(rect, this.htmluiControl1.Document);
}

 

VB

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
    LoadHTMLFile("doc.htm")
    Dim elem As IHTMLElement = Me.htmluiControl1.Document.RenderRoot
    Dim lastPoint As Point = New Point(0, (elem.Location.Y + elem.Size.Height))
    Dim rect As Rectangle = New Rectangle(New Point(10, lastPoint.Y - 10), New Size(10, 10))
    Me.htmluiControl1.ScrollToRectangle(rect, Me.htmluiControl1.Document)
End Sub

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied