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; procedure TCustomStringGrid.InsertRowWithValues(Index: Integer;
Values: array of String); Values: array of String);
var var
i, OldRC: Integer; i, OldRC, Diff: Integer;
begin begin
OldRC := RowCount; OldRC := RowCount;
if Length(Values) > ColCount then Diff := Length(Values) - ColCount;
ColCount := Length(Values); 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); InsertColRow(false, Index);
//if RowCount was 0, then setting ColCount restores RowCount (from FGridPropBackup) //if RowCount was 0, then setting ColCount restores RowCount (from FGridPropBackup)
//which is unwanted here, so reset it (Issue #0026943) //which is unwanted here, so reset it (Issue #0026943)