unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Contnrs, StdCtrls;
type
TForm1 =
class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private-Deklarationen }
ComponentList: TComponentList;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
cb: TComboBox;
begin
cb := TComboBox.Create(self);
cb.Parent := self;
cb.Top := (ComponentList.Count * (cb.Height + 3));
// weitere eigenschaften setzen
cb.Items.Add(DateTimeToStr(now));
// mit irgendein Text blabla Text füllen
cb.ItemIndex := 0;
ComponentList.Add(cb);
Caption := '
ComponentList: ' + IntToStr(ComponentList.Count);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
cb: TComboBox;
begin
if ComponentList.Count > 0
then
begin
cb := TComboBox(ComponentList[ComponentList.Count-1]);
cb.Free;
Caption := '
ComponentList: ' + IntToStr(ComponentList.Count);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ComponentList := TComponentList.Create;
Caption := '
ComponentList: ' + IntToStr(ComponentList.Count);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
ComponentList.Free;
end;
end.