Delphi遍历控件

1.如何遍历一个panel中所有的控件?

Var
i:integer;
begin
fori:=0toPanel1.ControlCountdo
begin
//控件:Panel1.Controls[i]
//加入自己代码
end;
end;

2. 有10个EDIT控件,取名为EDT1,EDT2,EDT3。。。EDT10,如何用一个循环知道哪个EDIT控件的值是空的?

procedure TForm1.Button2Click(Sender: TObject);
var
I:integer;
begin
for i:=0 to Self.Componentcount-1 do//Self.Componentcount就是TForm1的控件数量
begin
if Self.Components[i] is TEdit then //判断控件是否为TEdit
begin
if (Self.Components[i] as TEdit).Text='' then ShowMessage(Self.Components[i].Name);
end;
end;
end;
利用这个function FindComponent(const Name: string)函数你可以找到你要的任何控件,然后判断它是否为空. 使用Tedit.findcomponents(edit(I))函数,i为控件的序号,具体看一下帮助!
<clk>还有一个<nobr οnmοusemοve="kwM(5);" οnmοuseοut="kwL(event,this)" οnmοuseοver="kwE(event,5, this);" οncοntextmenu="return false;" target="_blank" οnclick="return kwC(event,5)" style="background: transparent url(http://control.clickeye.com.cn/images/line5.gif) repeat-x scroll center bottom; padding-bottom: 2px; color: rgb(102, 0, 255); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" id="clickeyekey5">方法</nobr>就是给他们的TAG赋同一个值,比如1,其他默认为零,程序如下: </clk>
procedure TForm1.Button2Click(Sender: TObject);
var
I:integer;
begin
for i:=0 to Self.Componentcount-1 do//Self.Componentcount就是TForm1的控件数量
begin
if Self.Components[i] is TEdit then //判断控件是否为TEdit
begin
if (Self.Components[i] as TEdit).Text='')
and (Self.Components[i] as TEdit).tag=1) then
ShowMessage(Self.Components[i].Name);
end;
end;
end;
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值