procedure SetCheck;
var
i: integer;
begin
with Form1 do
for i := 0 to ComponentCount - 1 do
if Components is TCheckBox then
TCheckBox(Components).Checked := True;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
SetCheck;
end;
哎, 晚了
不过我认为
for i := controlcount-1 downto 0 do
if controls is TCheckBox then
TCheckBox(controls).checked := True;
更好
1. 循环时不会访问不可见控件比如TTable.
2. 所有twincontrol都在tcontrol后面, tcheckbox是TWinControl, 倒查会快点