我在窗体上有50个TEdit控件,我想取前n(n<50且是个不固定的数)个edit的内容
放到一个数组中,怎么才能实现呢?
谢谢大家!

解决方案 »

  1.   

    For I:=0 To ControlsCount-1 Do
      IF Controls[1] IS TEdit Then Begin
         //在这里写入处理代码.
        
      End;
      

  2.   

    var
      s: Array of string;
      j: integer;
    begin
      SetLength(s, 50);
      j :=0;
      For i:=0 To ControlsCount-1 Do
      IF Controls[1] IS TEdit Then 
      Begin
        j := j+1;
        if j>50 then exit;
        s[j] := Controls[i].text;
      End;
      

  3.   

    Index:=1;
    for i:=0 to ComponentCount-1 do
      if (Index=n) then
        exit
      else if Components[i].ClassType=TEdit then
      begin
        A[Index]:=(Components[i] as TEdit).Text;
        Index:=Index+1;
      end;