Also add
DataSource.DataSet.DisableControls;
and
DataSource.DataSet.EnableControls;
to beginning and ending of the
with Grid do block
to prevent flicker/scrolling of the DBGrid.
Replace lmax: array [0..30] of Integer; with lmax: array of Integer;. Add SetLength(lmax,Columns.Count - 1); just before the first for n := 0 to Columns.Count - 1 do.
]]>