Delphi不支持名解释,所以你不能这样做。
如果你想成批处理,只好用数组。
FlatBtns:Array[1..10]of TFlatButton;
先赋值
FlatBtns[1]:=FlatBtn1;
FlatBtns[2]:=FlatBtn2;
...
FlatBtns[10]:=FlatBtn10;然后就可以成批处理了。
如果你想成批处理,只好用数组。
FlatBtns:Array[1..10]of TFlatButton;
先赋值
FlatBtns[1]:=FlatBtn1;
FlatBtns[2]:=FlatBtn2;
...
FlatBtns[10]:=FlatBtn10;然后就可以成批处理了。
if form1.Component[i] is FlatButton then
FlatButton(Component[i]).free;
而你的变量是一个字符串,不是一个指针。
可改为
声明
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;
可以利用button的 tag属性,用个循环释放
if form1.Component[i] is FlatButton then
FlatButton(Component[i]).free;他们说Component没有定义,怎么办???
你的问题解决了,是不是想删掉无数的tFlatButton??下面的代码是我执行通过的, kesa(凯萨) 好几个地方打错了:)
for i:=0 to form1.ComponentCount-1 do
if form1.Components[i] is tFlatButton then
Components[i].free;
if Assigned(FindComponent('FlatButton'+Inttostr(i))) then
FindComponent('FlatButton'+Inttostr(i)).free ;
(FindComponent('FlatButton'+inttostr(MyCount)) as TComponent).Free;