有多个edit控件,edit1,edit2.......edit10,现在想让它们都清空,有办法一次
性清空吗?

解决方案 »

  1.   

    var
      i:integer;
    begin
       for i:=0 to ComponentCount-1 do
          begin
            if (Components[i] is Tedit) then (Components[i] as Tedit).Clear;
          end;
    end;
      

  2.   

    for i := 0 to Controlcount do
       if controls[i] is Tedit then
          (controls[i] as tedit).text := ''
      

  3.   

    for i := 1 to 10 do
      TEdit(FindComponent('Edit'+IntToStr(i))).Text := '';
      

  4.   

    for i:=0 to componentcount-1 do
      begin
        temp:=components[i];
        if temp is tedit then
          (temp as tedit).Text:=''
        else
          if temp is tcombobox then
            (temp as tcombobox).Text:='';
      end;