anchor.diff:          n := n.parent;
         end;
       end;
  -    
  -    if GetAbsoluteNodeTop(Selection) + GetNodeHeight - FVScrollbar.Position > VisibleHeight then
  -    begin
  -      FVScrollbar.Position := GetAbsoluteNodeTop(Selection) + GetNodeHeight - VisibleHeight;
  +
  +    dy := GetAbsoluteNodeTop(FSelection);
  +    nh := GetNodeHeight;
  +    vh := VisibleHeight;
  +    if dy + nh - FVScrollbar.Position > vh then
  +    begin
  +      if FVScrollBar.Max = 0 then    // the first time and no expansion happened before.
  +        FVScrollBar.Max := dy + Height;
  +      FVScrollbar.Position := dy + nh - vh;
         FYOffset := FVScrollbar.Position;
         UpdateScrollBars;
  +      if FHScrollbar.Visible then    // HScrollbar appeared so we need to adjust position again
  +      begin
  +        FVScrollbar.Position := FVScrollbar.Position + FHScrollbar.Height;
  +        FYOffset := FVScrollbar.Position;
  +        UpdateScrollBars;
  +      end;
       end;
       
  -    if GetAbsoluteNodeTop(Selection) - FVScrollbar.Position < 0 then
  -    begin
  -      FVScrollbar.Position := GetAbsoluteNodeTop(Selection);
  +    if dy - FVScrollbar.Position < 0 then
  +    begin
  +      FVScrollbar.Position := dy;
         FYOffset := FVScrollbar.Position;
         UpdateScrollbars;
       end;
  
positive.code: procedure TfpgTreeview.SetSelection(const AValue: TfpgTreeNode);
  var
    n: TfpgTreeNode;
  begin
    if aValue <> FSelection then
    begin
      FSelection := aValue;
      if aValue <> nil then
      begin
        n := aValue.parent;
        while n <> nil do
        begin
          n.Expand;
  
negative.code:     keyRight:
        begin
          Consumed := True;
          Selection.Expand;
          DoExpand(Selection);
          ResetScrollbar;
          RePaint;
  