From 8ff1d3962b3ce366eedbba3e1b10a0c7ca08df6e Mon Sep 17 00:00:00 2001 From: bart <9132501-flyingsheep@users.noreply.gitlab.com> Date: Sun, 24 Feb 2013 14:21:53 +0000 Subject: [PATCH] ValEdit: InsertRow: if Append then insert after current row, not after last row. (According to Delphi help text) git-svn-id: trunk@40385 - --- lcl/valedit.pas | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/lcl/valedit.pas b/lcl/valedit.pas index ce303a2fe1..8535c70fe4 100644 --- a/lcl/valedit.pas +++ b/lcl/valedit.pas @@ -717,27 +717,35 @@ end; function TValueListEditor.InsertRow(const KeyName, Value: string; Append: Boolean): Integer; var - NewInd: Integer; + NewInd, NewCol: Integer; + Line: String; begin - Result := Row; + if (KeyName <> '') and (Value <> '') then + Line := KeyName + '=' + Value + else + Line := ''; if (Row > Strings.Count) or ((Row - FixedRows) >= Strings.Count) or (Cells[0, Row] <> '') or (Cells[1, Row] <> '') then begin // Add a new Key=Value pair Strings.BeginUpdate; try if Append then - NewInd := Strings.Count + NewInd := Row - FixedRows + 1 //append after current row else - NewInd := Result - FixedRows; - Strings.InsertItem(NewInd, KeyName+'='+Value, Nil); + NewInd := Row - FixedRows; //insert it at current row + Strings.InsertItem(NewInd, Line, Nil); finally Strings.EndUpdate; end; end else begin // Use an existing row, just update the Key and Value. - Cells[0, Result] := KeyName; - Cells[1, Result] := Value; + Cells[0, Row] := KeyName; + Cells[1, Row] := Value; + NewInd := Row - FixedRows; end; + Result := NewInd; + NewCol := NewInd + FixedRows; + if (NewCol <> Col) then Col := NewCol; end; procedure TValueListEditor.StringsChange(Sender: TObject);