利用Components属性,若Form中有其它容器,需要递归

解决方案 »

  1.   

    用窗体的Components属性遍历,如果是edit就clear
      

  2.   

    for i:=1 to n do
    form1.findcomponent('edit'+inttostr(i)) as tedit).text:='';
      

  3.   

    var 
      I : Integer;
    begin
      for I := 0 to Form1.ComponentCount-1 do
        if (Component[I] is TEdit) then
          (Component[I] as TEdit).Text := '';
    end; 
      

  4.   

      for i:=0 to (Self.ControlCount-1) do
      begin
         if Self.Controls[i] is TEdit then
           (Self.Controls[i] as TEdit).Text:='';
           或 
           TEdit(Self.Controls[i]).Text:='';
      end;
      

  5.   

    我的EDit控件是在GroupBox控件中的,我用了以上的方法,没有清空任何一个Edit啊
      

  6.   

    var i:integer
    begin
      for i:=0 to groupbox.controlcount-1 do
       if groupbox.controls[i] is tedit then
         tedit(groupbox.controls[i].text:='';
    end;
    这样试试吧
      

  7.   

    tedit(groupbox.controls[i]).text:=''
    不好意思这里少了一个括号