我现在想在a窗体里清空b窗体里的多个edit.text,请问怎么办
有人告诉我这么做
with tabSheet2 do
  begin
    for i:=0 to tabSheet2.ComponentCount-1 do
    begin
        if tabSheet2.Components[i].ClassType=Tedit  then
          Tedit( tabSheet2.Components[i]).Clear;
    end;
  end;
可是
tabSheet2.Components[i].ClassType=Tedit//这个tedit不对,因为这个tedit在别的b的窗体里,在本身a窗体里没有edit,所以不对,请问怎么办

解决方案 »

  1.   

    for i:= tabSheet2.ComponentCount-1 downto 0 do
        begin
            if tabSheet2.Components[i is Tedit  then
              Tedit( tabSheet2.Components[i]).Clear;
        end;
      

  2.   

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

  3.   

    我用的这个rzedit的控件,我是这么写的
     for I := 0 to lyybb.RzPanel3.ControlCount - 1 do
      begin
        if (lyybb.RzPanel3.Controls[I] is tRzEdit) then
           (lyybb.RzPanel3.Controls[I] as tRzEdit).Text := '';
      end;
    错误如下:
    [Error] main.pas(222): Undeclared identifier: 'tRzEdit'
      

  4.   

    这个写在a页(窗体a)里面,有b页(窗体b,窗口名为b),且已引用。
    var
    i : integer;
    begin
        for i:=0 to b.ComponentCount-1 do
        begin
            if b.Components[i] is Tedit  then
              Tedit( b.Components[i]).Text := '';
        end;
    绝对可以的,已测试过!
      

  5.   

    到b中找到 tRzEdit, Ctrl + 鼠标左键单击,看他到那个单元,或者看tRzEdit的帮助(有类似下面的东东
      Unit
      StdCtrls
    ),然后在a的Uses中添加那个单元。例如TEdit是在StdCtrls中。
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;//这里就要加上这个type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementationuses Unit2;{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    var
      i: integer;
    begin
      for i := 0 to Form2.ControlCount - 1 do
        if Form2.Controls[i] is TEdit then
          TEdit(Form2.Controls[i]).Clear;
    end;end.