I have several TPanels that are populated with buttons at runtime. However the code below that i use to free my buttons from their parent panels sometimes generates access violation errors.
procedure TfrmTakeOrder.FreeItemButtons(buttons : array of TButton);
var
cnt,i : integer;
begin
for i := 0 to gridLayoutItems.ControlCount - 1 do
begin
buttons[i].Free;
buttons[i] := nil;
end;
end;
Is there a better way to do this?Please keep in mind that other Panels have buttons too and I would like to have a "localised" freeing of the buttons that wount intefer with other panels.