在一个窗体中有不确定个TEDIT控件,我怎样确定有多少个呢?或怎样统计一个窗体中所有空间的个数?请帮忙!!!!!!!!!!!1
ar
i, j : integer;
strList : TStringList;
begin
strList := TStringList.Create;
strList.Add(aaaaaaa);
strList.Add(bbbbbbb);
strList.Add(ccccccc);
strList.Add(ddddddd);
j := 0;
for i := 0 to Self.ComponentCount -1 do
begin
if Self.Components[i] is TEdit then
begin
TEdit(Self.Components[i]).Text := strList.Strings[j];
j := j + 1;
end;
end;
strList.Free;
end;
以下是确定窗体有几个控件的例程
procedure TFDemo.Button2Click(Sender: TObject);
var
i,j:integer;
begin
j:=0;
for i:=0 to FDEmo.ControlCount-1 do
begin
if FDemo.Controls[i] is TEdit then
j:=j+1;
end;
showmessage(inttostr(j));////显示有几个EDIt 控件
end;