var i,a:Integer;
begin
for i:=1 to n do
begin
if ((mm_main.Items[10].Items[3].Caption<>'平铺') and (mm_main.Items[10].Items[3].Caption<>'层叠') and (mm_main.Items[10].Items[i-1].Caption<>'-') and (mm_main.Items[10].Items[3]<>nil)) then
begin
mm_main.Items[10].Items[3].Destroy;
mm_main.Items[10].Items[3].Free;
end;
end;
n:=0;
end;
begin
for i:=1 to n do
begin
if ((mm_main.Items[10].Items[3].Caption<>'平铺') and (mm_main.Items[10].Items[3].Caption<>'层叠') and (mm_main.Items[10].Items[i-1].Caption<>'-') and (mm_main.Items[10].Items[3]<>nil)) then
begin
mm_main.Items[10].Items[3].Destroy;
mm_main.Items[10].Items[3].Free;
end;
end;
n:=0;
end;
你的变量n超出了mm_main.Items[10].Items[i-1]的范围~~
还有就是清除的时候用mm_main.Items[10].Items[3].Free就行了。
for i:=1 to n -1 do