This is what the function looks like that populates the grid:
Code: Select all
procedure TMainForm.FillGrid;
begin
if Data = nil then Data := TStringsData.Create;
// Fill Header
for i := 0 to FieldCount - 1 do
begin
Data.Headers[i + 1] := FieldName(i);
end;
r := 0;
// Fill Cells
for i := 0 to FieldCount - 1 do
begin
Data.Rows := r + 1;
Data[i + 1 ,r] := FieldAsString(i);
end;
inc(r);
NextRecord;
end;
TeeGrid.Data := Data;
end;
The first run everything is fine, however, in a second run, if the number of columns increases, the header shows fine but the cells in the new columns are empty. I have tried calling Data.Free and/or TeeGrid.Columns.Clear and TeeGrid.Rows.Clear, but this doesn't help.
I need a way to reset the Data, how do I do this?
Thanks in advance,
Hans