var i: integer; for i:=self.componentcount-1 downto 0 do begin if (self.components[i] is TEdit) then if (self.components[i] as TEdit).Text:='条件' then begin self.components[i].free; self.components[i]:=nil; ; end; end;
destroy~~~~~~~~~~~~~~~~~~~~~~free.
可在一容器中创建控件, 如下: for I:=0 to ScrollBox1.controlcount-1 do begin if (ScrollBox1.Controls[I] is Tedit) then begin if Tedit(ScrollBox1.Controls[I]).name='your enter text' then Scrollbox1.Controls[i].free; end; end;
for i:=self.componentcount-1 downto 0 do
begin
if (self.components[i] is TEdit) then
if (self.components[i] as TEdit).Text:='条件' then
begin
self.components[i].free;
self.components[i]:=nil; ;
end;
end;
for I:=0 to ScrollBox1.controlcount-1 do
begin
if (ScrollBox1.Controls[I] is Tedit) then
begin
if Tedit(ScrollBox1.Controls[I]).name='your enter text' then
Scrollbox1.Controls[i].free;
end;
end;
FreeAndNil()
安全释放,绝对好用,不会有什么内存出错等现象
再置句柄为空。