I have a TWebScrollBox
component on my form in a TMS WEB Core project.
I'm able to vertically scroll from Delphi programming code to various locations in the scrollbox using the ScrollTop
property on it.
So if I want to scroll to the top of the scrollbox, I can do the following:
WebScrollBox1.ScrollTop := 0;
But how can I scroll to the bottom of the scrollbox?
I tried getting the height of the scrollbox using various different properties such as Height
, ClientHeight
, ExplicitHeight
, etc. However, I wasn't able to get the actual height of the content in the scrollbox.
I managed to fake it for now by using Integer.MaxValue
like this:
WebScrollBox1.ScrollTop := Integer.MaxValue;
But obviously, that isn't the correct solution, because you're not setting it to the actual content height. Although unlikely, but possible: the content height could also be longer than Integer.MaxValue
.
What is the correct way to scroll to the actual bottom of the TWebScrollBox
component?
I eventually discovered that you can do this using the VertScrollBar.Range
property like this:
WebScrollBox1.ScrollTop := WebScrollBox1.VertScrollBar.Range;
This gets the actual height of the content in the TWebScrollBox
and sets the scrollbar to that causing it to scroll to the bottom.