unit frmListBox;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, uListBoxObjectClass;
type
TForm3 =
class(TForm)
ListBox1: TListBox;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Button1: TButton;
Edit4: TEdit;
procedure ListBox1Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
Test: TTest;
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
procedure TForm3.Button1Click(Sender: TObject);
var
strText:
String;
begin
Test:= TTest.Create;
// Object erstellen
Test.Wert1:= Edit1.Text;
// Text im Object ablegen
Test.Wert2:= Edit2.Text;
Test.Wert3:= Edit3.Text;
strText:= Edit4.Text;
ListBox1.AddItem(strText, Test);
// In die Listbox
end;
procedure TForm3.FormDestroy(Sender: TObject);
var
I: Integer;
begin
for i:= ListBox1.Count - 1
downto 0
do
begin
Test:= TTest(ListBox1.Items.Objects[i]);
if Test<>
NIL then
begin
freeAndNil(Test);
end;
end
end;
procedure TForm3.ListBox1Click(Sender: TObject);
var
I: Integer;
begin
for I := 0
to ListBox1.Count - 1
do
begin
if ListBox1.Selected[i]
then
begin
Edit1.Clear;
Edit2.Clear;
Edit3.Clear;
Edit1.Text:= TTest(ListBox1.Items.Objects[i]).Wert1;
Edit2.Text:= TTest(ListBox1.Items.Objects[i]).Wert2;
Edit3.Text:= TTest(ListBox1.Items.Objects[i]).Wert3;
end;
end;
end;
end.