Articles in this section
Category / Section

How to make the WinForms HTMLUIControl to scroll to a specific position during runtime?

1 min read

Scrolling

The HTMLUI supports scrolling which helps the user in loading large documents inside the HTMLUI control and navigate to desired locations easily. The user can toggle the scroll control visibility at runtime.

C#

//Scrolling is enabled in the control.
htmluiControl.AutoScroll = true;

 

VB

'Scrolling is enabled in the control.
htmluiControl.AutoScroll = true

Methods like the ScrollToElement() and ScrollToRectangle() helps the user to customize the scroll positions at run time. 

The ScrollToElement() method scrolls such that the specified HTML element is visible in the control.

The ScrollToRectangle() method scrolls such that the specified Rectangle is visible in the control.

 

C#

IHTMLElement div = htmluiControl.Document.GetElementByUserId("div");
IHTMLElement p = htmluiControl.Document.GetElementByUserId("p");
Rectangle rect = new Rectangle(p.Location, p.Size);
private void btnDiv_Click(object sender, System.EventArgs e)
{
     htmluiControl.ScrollToElement(div);
}
private void btnP_Click(object sender, System.EventArgs e)
{
     htmluiControl.ScrollToRectangle(rect, htmluiControl.Document);
}

 

VB

Dim div As IHTMLElement
Dim p As IHTMLElement
div = htmluiControl.Document.GetElementByUserId("div")
p = htmluiControl.Document.GetElementByUserId("p")
Rectangle rect = new Rectangle(p.Location, p.Size)
private void btnDiv_Click(object sender, System.EventArgs e)
{
    htmluiControl.ScrollToElement(div)
}
private void btnP_Click(object sender, System.EventArgs e)
{
    htmluiControl.ScrollToRectangle(rect, htmluiControl.Document)
}

Hence with the HTMLUI control, scrolling is made easier and customizable which helps in developing advanced user interfaces.

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