Free Dynamic SubReport component
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;
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;
This discussion has been closed.
Comments
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;