首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

delphi怎样遍历form1中的所有button控件解决方法

2012-04-18 
delphi怎样遍历form1中的所有button控件delphi怎样遍历form1中的所有button控件[解决办法]var i:integerb

delphi怎样遍历form1中的所有button控件
delphi怎样遍历form1中的所有button控件

[解决办法]
var i:integer;
begin
for i:=0 to ComponentCount-1 do //得到窗体的所有控件。
begin
if Components[i] is TButton then //判断是否是TButton类。
// if TButton(Components[i]).Focused then //判断是否有点焦
showmessage(TButton(Components[i]).Name);
end;
end;
[解决办法]

Delphi(Pascal) code
var i:integer;beginfor i:=0 to ComponentCount-1 do //得到窗体的所有控件。  begin  if Components[i] is TButton then //判断是否是TButton类。    if i=3 then      TButton(Components[i]).Caption:='我';  end;end; 

热点排行