如此即可:
for i:=0 to componentcount-1 do
if components is TPanle then
components.visible:=false;
或者用将panel's tag赋值<>0
for i:=0 to componentcount-1 do
begin
if components.tag=<>0
components.visible:=False;
end;
Happy3X的方法仅限于只有PANEL控件的情况,如在PANEL1、PANEL3之类的后面又放置
EDIT、LABEL等控件,就会出错,而且逐个设置TAG甚为麻烦,简单方法如下:
var i,j:integer;
begin
j:=0;
for i:=0 to ComponentCount-1 do
if Components is TPanel then
begin
j:=j+1;
if j=n then //n为指定值
(Components as TPanel).visible:=False;
end;
end;