onlinesoccer
Grünschnabel
Ich habe eine software geschrieben die den Inhalt der Listview in Records speichert di werden später auf eine Datei gschrieben .txt leider kann ich di jezt nich laden ich null ahnung bin neu in diesem gebiet helft mir bitte
PHP:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls;
type
TForm1 = class(TForm)
ListView1: TListView;
btnLaden: TButton;
btnSpeichern: TButton;
GroupBox1: TGroupBox;
Edit1: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
btnKsp: TButton;
Label5: TLabel;
Edit5: TEdit;
Label6: TLabel;
Label7: TLabel;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
procedure btnKspClick(Sender: TObject);
procedure btnSpeichernClick(Sender: TObject);
procedure btnLadenClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
TMyRecord = record
name, vorname, adresse, plz, ort: String[30];
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btnKspClick(Sender: TObject);
var
listitem:Tlistitem;
Kunden_anzahl: Integer;
begin
label7.Caption :='Anzahl Kunden = ' + IntToStr(ListView1.Items.Count);
ListItem:=TlistItem.Create(ListView1.Items);
ListItem.SubItems.Add(Edit1.text);
ListItem.SubItems.Add(Edit2.text);
ListItem.SubItems.Add(Edit3.text);
ListItem.SubItems.Add(Edit4.text);
ListItem.SubItems.Add(Edit5.text);
ListView1.Items.AddItem(ListItem);
Edit1.Text:='';
Edit2.Text:='';
Edit3.Text:='';
Edit4.Text:='';
Edit5.Text:='';
end;
procedure TForm1.btnSpeichernClick(Sender: TObject);
var
MyRecord: TMyRecord;
f:file of TMyRecord;
x:integer;
lItem: TListItem;
begin
assignfile(f,'C:\Var.txt');
rewrite(f);
begin
for x := 0 to ListView1.Items.Count-1 do
begin
lItem := ListView1.Items[x];
FillChar(MyRecord, SizeOf(MyRecord), #0);
MyRecord.name := lItem.SubItems[0];
MyRecord.vorname := lItem.SubItems[1];
MyRecord.adresse := lItem.SubItems[2];
MyRecord.plz := lItem.SubItems[3];
MyRecord.ort := lItem.SubItems[4];
Write(f,MyRecord);
end;
closefile(f)
end;
end;
procedure TForm1.btnLadenClick(Sender: TObject);
var
f:file of TMyRecord;
MyRecord: TMyRecord;
lItem: TListItem;
x:Integer;
begin
assignfile(f,'C:\Var.txt');
reset(f);
for x := 0 to ListView1.Items.Count-1 do
begin
read(f,MyRecord);
lItem := ListView1.Items[x];
lItem.SubItems[0]:= MyRecord.name;
lItem.SubItems[0]:= MyRecord.vorname;
lItem.SubItems[0]:= MyRecord.adresse;
lItem.SubItems[0]:= MyRecord.plz;
lItem.SubItems[0]:= MyRecord.ort;
end;
closefile(f)
end;
(*assignfile(f,'C:\Var.txt');
reset(f);
repeat
read(f,MyRecord);
lItem.SubItems[0] := MyRecord.name ;
until eof(f);
closefile(f)
end; *)
end.