We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How do I make the HTMLUI control to scroll to a specific position during runtime?

 

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.

C#

[HTML]

 

This is a sample text

 

  

The sample shows different scrolling features

   

The sample ends here

 

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.

Article ID: Published Date: Last Revised Date: Platform: Control:
823 04/30/2011 07/10/2014 Windows Forms HTMLUIControl
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.