假设我有十个LABEL控件,分别是LABEL1..LABEL10,我想同时设置他们的CAPTION属性都一样,LabelI.caption="";我想永I代替1到10,可以吗?/代码如何写???

解决方案 »

  1.   

    这样吧!var
     i :integer;
    begin
      for i := 0 to ComponentCount - 1 do 
          if Components[i] is Tlabel then
             Tlabel(Components[i]).caption="";
    end;
      

  2.   

    呵呵
    上面的有一点小错误(抄了你的:P) Tlabel(Components[i]).caption="";改为:
     Tlabel(Components[i]).caption := '';
      

  3.   

    呵呵
    说明一下var
     i :integer;
    begin
      for i := 0 to ComponentCount - 1 do     //ComponentCount----窗体上所有控件数
          if Components[i] is Tlabel then     //如果控件为Tlabel
             Tlabel(Components[i]).caption := '';   //lable1的caption为空
    end;