在一个窗体中有不确定个TEDIT控件,我怎样确定有多少个呢?或怎样统计一个窗体中所有空间的个数?请帮忙!!!!!!!!!!!1

解决方案 »

  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;
      

  2.   

    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;
      

  3.   

    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;
      

  4.   

    以下是确定窗体有几个控件的例程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;
      

  5.   

    其中FDEmo.ControlCount为窗体DEMO的控件数目
      

  6.   

    如果是窗体,则self.ComponentCount表示窗体上的控件数
    如果是统计在控件上的控件数,用:控件名.ControlCount