Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Free Dynamic SubReport component

edited June 2003 in General
I'm currently creating TppSubReport at runtime & i called this procedure at
ppDesigner1Close(event). The problem is i'm getting error message "List
Index Out Of Bounds (30)

procedure TfrmPrintProjectLetters.FreeSubReport;
var
intCounter: Integer;
begin
for intCounter := 0 to ComponentCount - 1 do begin
if (Components[intCounter] is TppSubReport) then begin
TppSubReport(Components[intCounter]).Free;
end
end;
end;

Comments

  • edited June 2003
    Hi nagen,

    when you delete a list item then the 'ComponentCount - 1' become less than 'i'! You should always use
    for intCounter := ComponentCount - 1 downto 0 do begin
    BTW, 'Components[intCounter].Free;' - you don't need the type cast because 'TObject.Free' is virtual.
    Doesn't the subreports have an owner?

    regards,
    Chris Ueberall;
  • edited June 2003
    thankx it's working
This discussion has been closed.