LCL: fix crash in TStringGrid.InsertRowWithValues is Columns.Enabled is True. Issue #0036067

git-svn-id: trunk@61946 -
This commit is contained in:
bart 2019-09-29 10:33:37 +00:00
parent 96eee65d5d
commit ed3cfadcf4

View File

@ -11761,11 +11761,19 @@ end;
procedure TCustomStringGrid.InsertRowWithValues(Index: Integer;
Values: array of String);
var
i, OldRC: Integer;
i, OldRC, Diff: Integer;
begin
OldRC := RowCount;
if Length(Values) > ColCount then
ColCount := Length(Values);
Diff := Length(Values) - ColCount;
if Diff > 0 then
begin
if Columns.Enabled then
begin
for i := 1 to Diff do with Columns.Add do Title.Caption := '';
end
else
ColCount := Length(Values);
end;
InsertColRow(false, Index);
//if RowCount was 0, then setting ColCount restores RowCount (from FGridPropBackup)
//which is unwanted here, so reset it (Issue #0026943)