with panel2 do
begin
for i:=0 to ControlCount - 1 do
begin
if controls[i] is tcheckbox then
begin
tcheckbox(controls[i]).Free;
end;
end;
end;
释放在panel2上动态创建的checkbox的时候出现list index out of bound(367)这个提示 不知道怎么解决
一开始的几个释放是可以的 因为checkbox比较多 有几百个 所以不知道具体释放到哪一个的时候出问题了 高手帮忙看下什么问题
begin
for i:=0 to ControlCount - 1 do
begin
if controls[i] is tcheckbox then
begin
tcheckbox(controls[i]).Free;
end;
end;
end;
释放在panel2上动态创建的checkbox的时候出现list index out of bound(367)这个提示 不知道怎么解决
一开始的几个释放是可以的 因为checkbox比较多 有几百个 所以不知道具体释放到哪一个的时候出问题了 高手帮忙看下什么问题
while(true) do begin
preCount := ControlCount;
for k := 0 to ControlCount - 1 do begin
// 释放
end;
if preCount <> ControlCount then Break;
end;
begin
...
for i:=n downto 0 do
...
begin
n:= ControlCount - 1
for i:=n downto 0 do
begin
if controls[i] is tcheckbox then
begin
tcheckbox(controls[i]).Free;
end;
end;
end;
应该是for i:=CotrolCount-1 downto 0 do
遍历TStrings释放控件;