假如控件名为:L1程序中.有字符串变量为:L
整数型变量为:i怎么合并才能让程序认到它是一个控件名,而不是字符串.类似于JS中的EVAL函数.('L' + inttostr(i)).cation=''; 是不行的.
Concat('L',IntToStr(i)).caption=''; 也是不行的.那怎么才行呢?

解决方案 »

  1.   

    FindComponent('L' + IntToStr(i));
      

  2.   

    Form1.FindComponent('L' + IntToStr(i)).Caption:='';还是不行
    出现这个错误
    [Error]Unit1.pas(91):Undeclared identifier:'Caption'直接用
    L25.Caption:='';就没事.
      

  3.   

    FindComponent返回的是TComponent型,Caption是TControl类才有的属性(注意TLabel继承自TControl),需要强制转换一下:TLabel(FindComponent('L' + IntToStr(i))).Caption := '';