If anybody likes,
Here's a small test-program
unit frm_MemoEmptyLineMain;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
btnClearMemo: TButton;
btnMemoAdd: TButton;
btnSetText: TButton;
btnAddText: TButton;
btnInsertText: TButton;
lblShowText: TLabel;
Memo1: TMemo;
procedure btnClearMemoClick(Sender: TObject);
procedure btnMemoAddClick(Sender: TObject);
procedure btnSetTextClick(Sender: TObject);
procedure btnAddTextClick(Sender: TObject);
procedure btnInsertTextClick(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.btnClearMemoClick(Sender: TObject);
begin
Memo1.Clear;
lblShowText.Caption:=''''+memo1.Text+'''';
end;
procedure TForm1.btnMemoAddClick(Sender: TObject);
begin
memo1.lines.add('Add Testline '+ inttostr(memo1.Lines.Count));
lblShowText.Caption:=''''+memo1.Text+'''';
end;
procedure TForm1.btnSetTextClick(Sender: TObject);
begin
memo1.lines.Text:='This is a test'+LineEnding+
'if there is alway an empty line'+LineEnding+
'at the end.';
lblShowText.Caption:=''''+memo1.Text+'''';
end;
procedure TForm1.btnAddTextClick(Sender: TObject);
begin
memo1.lines.AddText('AddText Testline '+ inttostr(memo1.Lines.Count));
lblShowText.Caption:=''''+memo1.Text+'''';
end;
procedure TForm1.btnInsertTextClick(Sender: TObject);
begin
memo1.lines.Insert(0,'Insert Testline '+ inttostr(memo1.Lines.Count));
lblShowText.Caption:=''''+memo1.Text+'''';
end;
end.
The form:
object Form1: TForm1
Left = 207
Height = 217
Top = 361
Width = 594
Caption = 'Form1'
ClientHeight = 217
ClientWidth = 594
LCLVersion = '1.4.0.4'
object Memo1: TMemo
Left = 0
Height = 176
Top = 0
Width = 320
Lines.Strings = (
'Memo1'
)
TabOrder = 0
end
object btnClearMemo: TButton
Left = 8
Height = 25
Top = 184
Width = 75
Caption = 'Clear'
OnClick = btnClearMemoClick
TabOrder = 1
end
object btnMemoAdd: TButton
Left = 92
Height = 25
Top = 184
Width = 75
Caption = 'Add'
OnClick = btnMemoAddClick
TabOrder = 2
end
object btnSetText: TButton
Left = 176
Height = 25
Top = 184
Width = 75
Caption = 'set Text'
OnClick = btnSetTextClick
TabOrder = 3
end
object btnAddText: TButton
Left = 256
Height = 25
Top = 184
Width = 75
Caption = 'AddText'
OnClick = btnAddTextClick
TabOrder = 4
end
object btnInsertText: TButton
Left = 336
Height = 25
Top = 184
Width = 75
Caption = 'Insert'
OnClick = btnInsertTextClick
TabOrder = 5
end
object lblShowText: TLabel
Left = 325
Height = 15
Top = 8
Width = 64
Caption = 'lblShowText'
ParentColor = False
end
end
The only way not to have an empty line, is to set the .text property directly.