自动生成界面的问题
wlq 2000-03-28 06:20:00 这是一数据库的录入界面,label的edit都是自动生成,请看代码,运行后,
我用componentcount方法没有发现组件生成,不知何故
......
type Label1=array[1..30] of Tlabel; //要生成的label和edit放在数组中
type edit1=array[1..30]of Tedit;
var
Form1: TForm1;
mylabel:label1;
myedit:edit1;
implementation
......
procedure TForm1.test1Click(Sender: TObject); //请看这一段,窗体上已经有了一个edit和
label,它们是两个数组mylabel[i]和myedit[i]的
第一个元素,为以后的元件提供基准位置
var i:integer;
llabel:Tlabel;
eedit:Tedit; //我把eedit,llabel做中间变量,create后赋给数组,赋完了
把它destroy,不知可否
begin
llabel:=Tlabel.Create(self);
eedit:=Tedit.Create(self);
mylabel[1]:=llabel;
myedit[1]:=eedit;
mylabel[1].caption:=content[0].field_bz;
myedit[1].text:=table1.FieldByName(content[0].field_name).asstring;
llabel.Destroy;
eedit.Destroy;
for i:=2 to count do begin //count是表的字段数
llabel:=Tlabel.Create(self);
mylabel[i]:=llabel;
myLabel[i].caption:=content[i-1].field_bz; //content是一个记录类型的数组,放数据字
典的,不必理它
mylabel[i].top:=mylabel[i-1].top+25;
mylabel[i].left:=mylabel[i-1].left;
mylabel[i].width:=mylabel[i-1].width;
mylabel[i].height:=mylabel[i-1].height;
mylabel[i].parent:=self;
mylabel[i].visible:=true;
llabel.Destroy;
end;
end;
我用form1的componentcount方法看不到组件生成.按理说在初始化时就该为两个Tlabel和Tedit类型的数组分配内存的?