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. Image for the cookie policy date

Scroll To End

I''d like to scroll the HTML control to the end. I''ve looked at the example "HTMLUIScrolling", but it has a small problem: It scrolls the X (Horizontal scrollbar) as well as the vertical. I can''t figure out how to get the horizontal scroll bar to stay at the far left. Actually, I''m not sure I understand the ScrollToRectangle() method at all. The example has: Rectangle rect = new Rectangle(new Point(lastPoint.X, lastPoint.Y-10), new Size(0,10)); this.htmluiControl1.ScrollToRectangle(rect, this.htmluiControl1.Document); I thought changing the rect to: //Rectangle rect = new Rectangle(new Point(0, lastPoint.Y-10), new Size(10,10)); would work, but it cause no scrolling to occur at all. Any ideas?

1 Reply

NR Nandakumar R Syncfusion Team May 25, 2006 07:25 AM UTC

Hi Eric, Thank you for pointing out the problem in the sample. This is corrected and will be available in the RTM version of Essential Studio 4.2. The HTMLUI control allows programmatic scrolling to a particular location or element with its extensive scroll properties support. One such method is the ScrollToRectangle method which adjusts the scrollbars to bring the specifed rectangle in to view. The suggestion you made failed because, the bounds in your suggestion are taken based on the bounds of the HTMLUI control. But the body tag element have some offset made internally for its display and the ScrollToRectangle requires a rectangle within the bounds of the document. So, we have to correct that offset inorder to get the coordinates for the rectangle to scroll. You can make the horizontal scrollbar at the far left with the help of the following code snippet. [C#] private void ScrollToEnd() { //Gets the body tag element IHTMLElement elem = this.htmluiControl1.Document.RenderRoot; Point lastPoint = new Point(0, (elem.Location.Y + elem.Size.Height)); //Rectangle adjusted to show the body element. Since it is necessary that the rectangle should be within the bounds of the document displayed in the htmlui control. Rectangle rect = new Rectangle(new Point(10, lastPoint.Y-10), new Size(10,10)); this.htmluiControl1.ScrollToRectangle(rect, this.htmluiControl1.Document); } Please refer the corrected sample, placed here as an attachment. Thank you for your interest in Syncfusion EssentialHTMLUI. Regards, Nanda HTMLUIScrolling.zip

Loader.
Live Chat Icon For mobile
Up arrow icon