unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;
type
TForm1 =
class(TForm)
RichEdit1: TRichEdit;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
private
{ Private-Deklarationen }
StringList1: TStringList;
StringList2: TStringList;
StringList3: TStringList;
function GetMaxLength(StringList: TStringList): Integer;
procedure AppendBlanks(
var StringList: TStringList; nLength: Integer);
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
nCount: Integer;
TabPixelPos1: Integer;
TabPixelPos2: Integer;
begin
StringList1.Add(Edit1.Text);
StringList2.Add(Edit2.Text);
StringList3.Add(Edit3.Text);
TabPixelPos1 := GetMaxLength(StringList1);
TabPixelPos2 := GetMaxLength(StringList2);
RichEdit1.Clear;
AppendBlanks(StringList1, TabPixelPos1);
AppendBlanks(StringList2, TabPixelPos2);
for nCount := 0
to StringList1.Count - 1
do
begin
RichEdit1.Lines.Add(StringList1[nCount] + '
' + StringList2[nCount] + '
' + StringList3[nCount]);
end;
RichEdit1.Repaint;
end;
function TForm1.GetMaxLength(StringList: TStringList): Integer;
var
nCount: Integer;
nLength: Integer;
begin
nLength := 0;
for nCount := 0
to StringList.Count - 1
do
begin
if nLength < Length(StringList[nCount])
then
nLength := Length(StringList[nCount]);
end;
result := nLength;
end;
procedure TForm1.AppendBlanks(
var StringList: TStringList; nLength: Integer);
var
nCount: Integer;
begin
for nCount := 0
to StringList.Count - 1
do
begin
while Length(StringList[nCount]) < nLength
do
begin
StringList[nCount] := StringList[nCount] + '
';
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
StringList1 := TStringList.Create;
StringList2 := TStringList.Create;
StringList3 := TStringList.Create;
end;
procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
FreeAndNil(StringList1);
FreeAndNil(StringList2);
FreeAndNil(StringList3);
end;
end.