This code, it loops when the calculation leads to navigating to the bottom row n(vertical orienntation, cell scrollmode)
procedure TfrmPlannerUI.MakeItemVisible(const AItem: TTMSFNCPlannerItem);
var
units : integer;
firstTime,
lastTime,
startTimeInView,
endTimeInView : TDateTime;
cell : TTMSFNCPlannerCell;
begin
if not AutoFitAppointments then
begin
case TimeInterval of
THPTimeInterval.Unknown: ;
THPTimeInterval.FiftheenMinutes: units := 15;
THPTimeInterval.FiveMinutes: units := 5;
end;
firstTime := IncMinute(DateOf(SelectedDate), trunc(planUI.TimeLine.DisplayStart*units));
lastTime := IncMinute(DateOf(SelectedDate), trunc(planUI.TimeLine.DisplayEnd*units));
startTimeInView := IncMinute(DateOf(SelectedDate), trunc((planUI.TimeLine.DisplayStart+planUI.VerticalScrollBar.ValueRange.Value)*units));
endTimeInView := IncMinute(startTimeInView, trunc(planUI.VerticalScrollBar.ViewportSize*units));
cell.Col := -1;
cell.Row := -1;
if (IncMinute(AItem.EndTime, 5)>=endTimeInView) then
cell := planUI.DateTimeToCell(Min(lasttime, IncMinute(AItem.EndTime, 15)));
if (IncMinute(AItem.StartTime, -5)<=startTimeInView) then
cell := planUI.DateTimeToCell(Max(firstTime, IncMinute(AItem.starttime, -15)));
if (cell.Col>-1) and (cell.Row>-1) then
planUI.Navigate(cell, False);
end;
end;