循环遍历同类控件:
form1中有groupbox1,内有多个speedbutton,控制其同时按下。
var i:integer;
begin
for i:=0 to form1.groupbox1.controlcount-1 do
if form1.groupbox1.controls[i] is tspeedbutton then
begin
tspeedbutton(form1.groupbox1.controls[i]).allowallup:=true;
tspeedbutton(form1.groupbox1.controls[i]).groupindex:=i+1;
tspeedbutton(form1.groupbox1.controls[i]).down:=true;
end;
结合数据库使用,表示表rz中的rz字段(bit),为1则按下,为0则抬起。
var i:integer;
begin
i:=0;
while not adotable1.eof then
if adotable1.fields[1].asboolen=true then
begin
tspeedbutton(form1.groupbox1.controls[i]).allowallup:=true;
tspeedbutton(form1.groupbox1.controls[i]).groupindex:=i+1;
tspeedbutton(form1.groupbox1.controls[i]).down:=true;
end
else
begin
tspeedbutton(form1.groupbox1.controls[i]).allowallup:=true;
tspeedbutton(form1.groupbox1.controls[i]).groupindex:=i+1;
tspeedbutton(form1.groupbox1.controls[i]).down:=false;
end;
inc(i);
adotable1.next;
end;
遍历Panel组件上的所有控件:
Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号
执行时间: 0.041023015975952 seconds