Creating or Destroying of Multiple Controls at Runtime

If your application requires creating (or destroying) a large number of controls dynamically, it is recommended to call SuspendLayouts() before proceeding to create them.

circle-exclamation

Example:

Delphi / Pascal
SuspendLayouts;

try
  for I := 1 to 20 do
  begin
    B := TUniDBGrid.Create(Self); // create 20 grids dynamically
    B.DataSource := DataSource1;
    B.Parent := UniContainerPanel1;
    ...
  end;
finally
  ResumeLayouts;
end;

Calling SuspendLayouts() is especially useful when you are inserting new controls into an already created and rendered Form or Frame.