可以把复选框加在一个容器上也可以 直接是 窗体上
方法1(窗体上):
var
i:integer;
begin
for i:=1 to form1.ComponentCount do
begin
if form1.Components[i-1] is Tcheckbox then
begin
if Tcheckbox(form1.Components[i-1]).checked then
showmessage(Tcheckbox(form1.Components[i-1]).caption);
end;
end;
end;
方法2(容器上):
with GroupBox1 do
begin
for i:=0 to ControlCount-1 do
if Controls[i] is Tcheckbox then
begin
if Tcheckbox(Controls[i]).checked then
z :=Tcheckbox(Controls[i]).caption;
Dialogs.ShowMessage(z); //同等于showmessage(z);
end;
end;
本文来自博客园,作者:del88,转载请注明原文链接:https://www.cnblogs.com/del88/archive/2011/11/06/2238201.html