可不可以写很少的代码就清除窗体中所有TEdit中的文字,而不需写Edit1.text:='';Edit2.Text:='';.............

解决方案 »

  1.   

    好象不行~
    edit[i]?
    不行啊~
      

  2.   

    var i:integer;
    begin
     for i:= 0  to form1.componentcount-1 do  //不好意思componentcount记不太清!!
         if components[i] is Tedit then //遍历窗体的所有控件,并判断是否是Tedit类型的.
           (components[i] as Tedit).text:='';//如果是则把它清空
    end;如果错误,真的很抱歉!!!但是基本上是这样.
      

  3.   

    for i := 0 to ComponentCount - 1 do
        begin
        if Components[i] is TsuiEdit then
          (Components[i] as TsuiEdit).Text := '';
        if Components[i] is TsuiCheckBox then
          (Components[i] as TsuiCheckBox).Checked := False;
        if Components[i] is TsuiCheckListBox then
          (Components[i] as TsuiCheckListBox).Items.Clear;
        end;
      

  4.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      i:integer;
    begin
     for i:=0 to form1.ComponentCount-1 do
       if Components[i] is tedit then (components[i] as tedit).Text:='';
    end;
      

  5.   

    for i:=0 to form1.ComponentCount-1 do
       if Components[i] is tedit then (components[i] as tedit).Text:='';
      

  6.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      i: Integer;
    begin
      for i:=1 to 2 do
        TEdit(FindComponent('Edit'+IntToStr(i))).Clear;
    end;
      

  7.   

    for i := 0 to ComponentCount - 1 do
        begin
        if Components[i] is TsuiEdit then
          (Components[i] as TsuiEdit).Text := '';
        if Components[i] is TsuiCheckBox then
          (Components[i] as TsuiCheckBox).Checked := False;
        if Components[i] is TsuiCheckListBox then
          (Components[i] as TsuiCheckListBox).Items.Clear;
        end;
      

  8.   

    我靠,什么世道啊,我来的晚,没回答,因为楼上的几位说的很清楚,可是比我来的还晚的,跟delphi0302(好好学习,天天向上!) 说的一样,居然分最高,有点。。
      

  9.   

    我靠,什么世道啊,我来的晚,没回答,因为楼上的几位说的很清楚,可是比我来的还晚的,跟delphi0302(好好学习,天天向上!) 说的一样,居然分最高,有点。。