Hi,
ich hab mir folgende TEST-Kompo geschrieben.
Delphi-Quellcode:
unit ScrollBox1;
interface
uses
SysUtils, Classes, Controls, Forms, Stdctrls;
type
TItem =
class(TCollectionItem)
private
fCaption: TCaption;
published
property Caption: TCaption
read fCaption
write fCaption;
end;
type
TScrollBoxtest =
class(TScrollBox)
private
fItems: TCollection;
protected
procedure setitems(value: Tcollection);
public
procedure Refresh;
published
constructor Create(Aowner: tComponent);
override;
destructor Destroy;
override;
property items: tcollection
read fitems
write setitems;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('
Samples', [TScrollBoxtest]);
end;
constructor tScrollboxtest.Create(Aowner: TComponent);
begin
inherited Create(Aowner);
fitems := TCollection.Create(titem);
end;
destructor tscrollboxtest.Destroy;
begin
fItems.Free;
inherited destroy;
end;
procedure tscrollboxtest.Refresh;
var
i: Integer;
lbl: TLabel;
begin
for i := ComponentCount -1
downto 0
do
Components[i].Free;
for i := 0
to fItems.Count -1
do
begin
lbl := TLabel.Create(Self);
lbl.Align := altop;
lbl.Caption := (fitems.items[i]
as titem).Caption;
lbl.Refresh;
lbl.Parent := self;
lbl.Visible := true;
end;
end;
procedure tscrollboxtest.setitems(value: TCollection);
begin
fitems.Assign(value);
refresh;
end;
end.
Wenn ich jetzt während der Runtime refresh aufrufe werden alle Labels angezeigt. Was muss ich tun damit diese bereits bei der DesignTime zu sehen sind?