The DisplayRectangle property of the control is calculated incorrectly when the TreeViewAdv control is not visible. TVA asks the scroll bar controls (_vScrollBar and _hScrollBar) if they are visible then uses that information to calculate the DisplayRectangle. However if the tree view control itself changes to not visible, then the scroll bars will turn not visible as well temporarily whether or not the scrolling area is larger than the DisplayRectangle. The control needs to store whether the scroll bars are supposed to be visible or not when it sets the Visible property and calculate the DisplayRectangle based on the stored state, not whether they are actually visible at the moment.
The incorrect calculation of the DisplayRectangle during the time the control is populated while not visible leads the control to be unable to scroll all the way to the bottom of the list when it becomes visible if it was wide enough and long enough that both the horizontal and vertical scroll bars should be active. This is because the control calculated the wrong number of lines per page using the faulty DisplayRectangle value.
In TreeViewAdv.cs
Add this function to update the scroll bars when tree become visible:
protected override void OnVisibleChanged(EventArgs e)
{
if (Visible)
SafeUpdateScrollBars();
base.OnVisibleChanged(e);
}
In function UpdateScrollBars, I add the first line (_hScrollBar.Visible = false), because sometimes VScrollBar height is wrong.
private void UpdateScrollBars()
{
_hScrollBar.Visible = false;
UpdateVScrollBar();
UpdateHScrollBar();
UpdateVScrollBar();
UpdateHScrollBar();
_hScrollBar.Width = DisplayRectangle.Width;
_vScrollBar.Height = DisplayRectangle.Height;
}