ScrollToEnd() / ScrollToBegin()?

Nov 15, 2013 at 3:16 PM
Edited Nov 15, 2013 at 3:20 PM
Hi there, what is the easiest way to scroll to end after adding some content? Or scroll to top of document? Some background...

I've wrapped the HtmlPanel into a ScrollableHtmlPanel which allows the use of my own custom scroll bars, everything works great, the Home and End keys do what they should, but programmatically I can't find a way to scroll the panel without setting focus and sending a Home or End key to the control. This works naturally, but has other side effects.

I have a similar control which wraps a RichTextBox, and in that case I was able to implement my own scroll-to methods by using the RichTextBox.Select() method. I'm looking for something similar to HtmlPanel but so far no luck.

Thanks in advance!

P.S. I forgot to add: AutoScroll is set to true...
Nov 15, 2013 at 3:31 PM
Nevermind, I found this:

At first it didn't work the way I expected, but the problem was a redundant Invalidate().

So I added the following to my SimpleHtmlPanel wrapper:
    public void GoToStart()
        AutoScrollPosition = new Point(HorizontalScroll.Minimum, VerticalScroll.Minimum); 

    public void GoToEnd()
        AutoScrollPosition = new Point(HorizontalScroll.Maximum - HorizontalScroll.LargeChange, VerticalScroll.Maximum - VerticalScroll.LargeChange);        
Works like a charm!
Nov 16, 2013 at 11:48 AM
Great you found a solution.
If you run in other problems I may suggest to either use the HtmlLabel so you won't have an issue with panel inside a panel or to use the HtmlContainer directly to have the best control over it.
Using the HtmlContainer directly might be a bit more complex but it will provide more power, that's what I did in my project.
Mar 10, 2014 at 6:50 AM
Can this be included in the actual HtmlContainer control? It would be incredibly convenient.
Mar 10, 2014 at 8:26 AM
HtmlContainer is low-level component that has no knowledge of scrolling.
If you mean to add it to HtmlPanel then I'm not sure I want to add something that Framework developers didn't add themselves...
Mar 11, 2014 at 10:56 AM
My mistake; I did mean to say HtmlPanel.