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

dsdgddg 2012-04-02 07:09:54
delphi怎样遍历form1中的所有button控件
...全文
312 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
cdchq 2012-04-02
  • 打赏
  • 举报
回复

var i:integer;
begin
for i:=0 to ComponentCount-1 do //得到窗体的所有控件。
begin
if Components[i] is TButton then //判断是否是TButton类。
if i=3 then
TButton(Components[i]).Caption:='我';
end;
end;
dsdgddg 2012-04-02
  • 打赏
  • 举报
回复
比如我想button3的Caption为'我',但焦点不一定在button3上这该怎么写
有时又想button4的Caption为'我'
dsdgddg 2012-04-02
  • 打赏
  • 举报
回复
如果我想第i个button的cation为'我'
但焦点不一定在这个button上,这语句该怎么写?
无条件为你 2012-04-02
  • 打赏
  • 举报
回复
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;
dsdgddg 2012-04-02
  • 打赏
  • 举报
回复
而且我要知道当前焦点在哪个button控件,以及获得该button的name名称

5,390

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧