Delphi不支持名解释,所以你不能这样做。
如果你想成批处理,只好用数组。
FlatBtns:Array[1..10]of TFlatButton;
先赋值
 FlatBtns[1]:=FlatBtn1;
 FlatBtns[2]:=FlatBtn2;
...
 FlatBtns[10]:=FlatBtn10;然后就可以成批处理了。

解决方案 »

  1.   

    for i:=0 to form1.ComponentCount-1 do
      if form1.Component[i] is FlatButton then
         FlatButton(Component[i]).free;
      

  2.   

    function assigned(var p):boolean;
    而你的变量是一个字符串,不是一个指针。
    可改为
    声明 
    var
      flatbutton:array of Tflatbutton;
      mycount:integer;   
    实现
      mycount:=10;
      setlength(flatbutton,mycount);
      ..........
      for mycount:=0 to 9 do
      begin
        if Assigned(FlatButton[mycount]) then
        begin
         FlatButton[mycount].Free;
        end;
      end;
      
      

  3.   

    delphi不支持你的语法,
    可以利用button的 tag属性,用个循环释放
      

  4.   

    for i:=0 to form1.ComponentCount-1 do
      if form1.Component[i] is FlatButton then
         FlatButton(Component[i]).free;他们说Component没有定义,怎么办???
      

  5.   

    是Components[i],不好意思。我忘记打s了
      

  6.   

    To helpmepls:
    你的问题解决了,是不是想删掉无数的tFlatButton??下面的代码是我执行通过的, kesa(凯萨) 好几个地方打错了:)
     for i:=0 to form1.ComponentCount-1 do
      if form1.Components[i] is tFlatButton then
         Components[i].free;
      

  7.   

    for i:= 1 to 10 do
        if Assigned(FindComponent('FlatButton'+Inttostr(i))) then
           FindComponent('FlatButton'+Inttostr(i)).free ;
      

  8.   

    for MyCount := 1 to 10 do
      (FindComponent('FlatButton'+inttostr(MyCount)) as TComponent).Free;