So. Genau so wie Chewie es sagt geht es:
Delphi-Quellcode:
type
TPerson = record
Name: string[255];
Vorname: string[255]
end;
PPerson = ^TPerson;
procedure TForm1.btnAddClick(Sender: TObject);
var
Person: PPerson;
begin
new(person);
Person^.Name := edtName.Text;
Person^.Vorname := edtVorname.Text;
Listbox1.Items.AddObject(IntToStr(Listbox1.Items.Count + 1), TObject(Person));
end;
procedure TForm1.ListBox1Click(Sender: TObject);
var
Name, Vorname: string;
begin
if Listbox1.ItemIndex > -1 then
begin
Name := PPerson(Listbox1.Items.Objects[Listbox1.ItemIndex])^.Name;
Vorname := PPerson(Listbox1.Items.Objects[Listbox1.ItemIndex])^.Vorname;
ShowMessage(name + ', ' + Vorname);
end;
end;
procedure TForm1.FormDestroy(Sender: TObject);
var
Loop: Integer;
begin
for Loop := 0 downto Listbox1.Items.Count - 1 do
Dispose(PPerson(Listbox1.Items.Objects[Loop]));
end;