I have several TPanels that are filled with buttons at runtime. However, the code below, which I use to release buttons from my 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, and I would like to have a βlocalizedβ release of buttons that combine with other panels.
source share