delphi xe5如何在Android平台下刪除已經動態創建的組件
delphi xe5如何在Android平台下刪除已經動態創建的組件,各位大師幫忙看一下,這段代碼哪裡有不合適?為甚麼運行時第二次按下button程序會自動退出;代碼如下:
procedure TForm4.Button3Click(Sender: TObject);
var
i:integer;
scrollboxA: Tscrollbox;
panelD:Tpanel;
Begin
For i :=ComponentCount-1 downto 0 do
begin
If (Tscrollbox(Components[i]).Name='ScrollBox1') Then
Tscrollbox(Components[i]).Free;
end;
scrollboxA:=Tscrollbox.Create(form4);
scrollboxA.Name:='ScrollBox1';
scrollboxA.Position.X:=184;
scrollboxA.Position.y:=112;
scrollboxA.Width:=641;
scrollboxA.Height:=420;
scrollboxA.Parent:=form4;
for i:=1 to 5 do
begin
panelD:=Tpanel.Create(Self);
With panelD do
begin
Name:='panels'+InttoStr(i+1);
Parent:=scrollboxA;
Height:=89;
Align := TAlignLayout.alTop;
end;
end;
end;
----------------------------------------------