如果我想把edit1,edit2,edit3....edit20的visible:=false;
不用edit1.visible:=false;edit2.visible:=false;....(略).....edit20.visible:=false;
用什么办法比较快?有什么函数可以遍历组件的?

解决方案 »

  1.   

    先获取第一个edit的handle
    再调用getnextwindow即可
      

  2.   

    reedseutozte(haha):你能不能举个例子,我还是看不懂?
      

  3.   

    有两个方法:第一个方法,将这些组件放在一个Panel上,然后将Panel的Visible设为False即可。
      

  4.   

    看不下去了!
    TEdit(self.FindComponent('edit' + IntToStr(i)))).Visible := False ;明白了吗?
      

  5.   

    第二个方法,实用编程:procedure TForm1.Button1Click(Sender: TObject);
    var
      i:integer;
      edit:TEdit;
    begin
      for i:=0 to 100 do
      begin
        edit:=TEdit(form1.FindComponent('edit'+intToStr(i)));
        if edit<>nil then
          edit.Visible:=false;
      end;
    end;
      

  6.   

    for i:=0 to self.componentcount-1 do
      if self.component[i] is Tedit then
        (self.component[i] as tedit).visible:=false;
      

  7.   

    for i  :=  4 to Self.ComponentCount - 1 do
        if (Self.Components[i] is TEdit) then
        (Self.Components[i] As TEdit).Clear;   这也是一种方法
      

  8.   

    这个问题好象问了好多次了,自己去search一下
      

  9.   

    for i:=0 to Form1.ComponentCount-1 do
    begin
     if   (Form1.Components[i] is TEdit) then
     begin
        TEdit(Form1.Components[i]).Visible:=false
     end;
    end;