mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-08 04:35:57 +02:00
ValEdit: InsertRow: if Append then insert after current row, not after last row.
(According to Delphi help text) git-svn-id: trunk@40385 -
This commit is contained in:
parent
41464aaec9
commit
8ff1d3962b
@ -717,27 +717,35 @@ end;
|
|||||||
|
|
||||||
function TValueListEditor.InsertRow(const KeyName, Value: string; Append: Boolean): Integer;
|
function TValueListEditor.InsertRow(const KeyName, Value: string; Append: Boolean): Integer;
|
||||||
var
|
var
|
||||||
NewInd: Integer;
|
NewInd, NewCol: Integer;
|
||||||
|
Line: String;
|
||||||
begin
|
begin
|
||||||
Result := Row;
|
if (KeyName <> '') and (Value <> '') then
|
||||||
|
Line := KeyName + '=' + Value
|
||||||
|
else
|
||||||
|
Line := '';
|
||||||
if (Row > Strings.Count) or ((Row - FixedRows) >= Strings.Count)
|
if (Row > Strings.Count) or ((Row - FixedRows) >= Strings.Count)
|
||||||
or (Cells[0, Row] <> '') or (Cells[1, Row] <> '') then
|
or (Cells[0, Row] <> '') or (Cells[1, Row] <> '') then
|
||||||
begin // Add a new Key=Value pair
|
begin // Add a new Key=Value pair
|
||||||
Strings.BeginUpdate;
|
Strings.BeginUpdate;
|
||||||
try
|
try
|
||||||
if Append then
|
if Append then
|
||||||
NewInd := Strings.Count
|
NewInd := Row - FixedRows + 1 //append after current row
|
||||||
else
|
else
|
||||||
NewInd := Result - FixedRows;
|
NewInd := Row - FixedRows; //insert it at current row
|
||||||
Strings.InsertItem(NewInd, KeyName+'='+Value, Nil);
|
Strings.InsertItem(NewInd, Line, Nil);
|
||||||
finally
|
finally
|
||||||
Strings.EndUpdate;
|
Strings.EndUpdate;
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else begin // Use an existing row, just update the Key and Value.
|
else begin // Use an existing row, just update the Key and Value.
|
||||||
Cells[0, Result] := KeyName;
|
Cells[0, Row] := KeyName;
|
||||||
Cells[1, Result] := Value;
|
Cells[1, Row] := Value;
|
||||||
|
NewInd := Row - FixedRows;
|
||||||
end;
|
end;
|
||||||
|
Result := NewInd;
|
||||||
|
NewCol := NewInd + FixedRows;
|
||||||
|
if (NewCol <> Col) then Col := NewCol;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TValueListEditor.StringsChange(Sender: TObject);
|
procedure TValueListEditor.StringsChange(Sender: TObject);
|
||||||
|
Loading…
Reference in New Issue
Block a user