tt:=tlabel.Create(self); //创建LABEL
comcount:=comcount+1;
tt.Name:='compo'+inttostr(comcount); //以compo+序号来命名控件
tt.Top:=10+(j mod 7)*(44+5);
tt.Left:=30+((j mod 21) div 7)*220;
tt.Caption:='compo'+inttostr(comcount);
procedure TForm1.SpeedButton1Click(Sender: TObject);
var
edt:array of TEdit;
lbl:array of Tlabel;
i,iCount:integer;
begin
iCount:= table1.FieldCount;
setlength(edt,iCount);
setlength(lbl,iCount);
for i:=0 to iCount-1 do
begin
procedure TForm1.Button1Click(Sender: TObject); //增加组件
var i:integer;
Edit:TEdit;
begin //以Tag为标准.
for i:=0 to ListBox1.Items.Count-1 do
begin
Edit:=TEdit.Create(self);
Edit.Name:='Edit'+ListBox1.Items.Strings[i];
Edit.Parent:=self;
Edit.Left:=i*60;
Edit.Top:=i*5;
Edit.Tag:=strtoint(ListBox1.Items.Strings[i]);
end;
end;
procedure TForm1.Button2Click(Sender: TObject); //查看组件数
var i,n:integer;
str,str1:string;
begin
n:=0;
str:='';
showmessage('组件数:'+inttostr(self.ComponentCount));
for i:=0 to self.ComponentCount-1 do
begin
if self.Components[i].ClassName='TEdit' then
begin
n:=n+1;
str:=str+' '+self.Components[i].Name;
case self.Components[i].Tag of
100: begin ...你要对这个控件做的事.. end;
111: begin ...你要对这个控件做的事.. end;
{ ..........}
end;
end;
end;
showmessage('TEdit组件数:'+Inttostr(n));
showmessage(str);
end;
{ 此例已测试过. }