)
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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to reset the scroll position programmatically in WinForms HTMLUIControl?

Platform: WinForms |
Control: HTMLUIControl |
Published Date: April 30, 2011 |
Last Revised Date: January 3, 2020

Reset the scroll position

The scroll position can be moved programmatically to show the selected item with the help of the ScrollToElement method of the HTMLUI control. The ScrollToElement method helps the user to scroll to a position such that the specified element is visible in the HTMLUI control.

The following HTML document contains a div element and the code snippet below shows how the HTMLUI control is scrolled to make the div element visible.

Essential Studio is available with full source code. It incorporates a unique debugging support system that allows switching between 'Debug' and 'Release' versions of our library with a single click from inside the Visual Studio.NET IDE.

 

C#

private System.Windows.Forms.Button button1;
DIVElementImpl div;
private void htmluiControl1_LoadFinished(object sender, System.EventArgs e)
{
    Hashtable html = this.htmluiControl1.Document.GetElementsByUserIdHash();
    this.div = html["div1"] as DIVElementImpl;
}
private void button1_Click(object sender, System.EventArgs e)
{
    this.htmluiControl1.ScrollToElement(this.div);
}

 

VB

Private button1 As System.Windows.Forms.Button
Private div As DIVElementImpl
Private Sub htmluiControl1_LoadFinished(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim html As Hashtable = Me.htmluiControl1.Document.GetElementsByUserIdHash()
    Me.div = CType(IIf(TypeOf html("div1") Is DIVElementImpl, html("div1"), Nothing), DIVElementImpl)
End Sub
Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
    Me.htmluiControl1.ScrollToElement(Me.div)
End Sub

 

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon