关于动态访问的问题

fantasylu 2003-10-15 05:57:35
如果我有6个 button1~button6
如果我想把button1~button6的caption改变,因该怎样做?
...全文
26 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Kabin 2003-10-15
  • 打赏
  • 举报
回复
遍历对象
for(int i=1;i<ComponentCount;i++)
{
if(String(Components[i]->ClassName()) == "TButton")
{
TButton *theButton = (TButton *)Components[i];
theButton->Caption = "your caption";
}
}
mabc 2003-10-15
  • 打赏
  • 举报
回复
呀!老妖怎么不给我们这些后来者点机会呀!!
哈哈!
ccrun.com 2003-10-15
  • 打赏
  • 举报
回复
TList *list=new TList();
list->Add(Button1);
list->Add(Button2);
list->Add(Button3);
list->Add(Button4);
list->Add(Button5);
list->Add(Button6);
for(int i=0;i<list->Count;i++)
{
((TButton *)list->Items[i])->Caption="新标题";
}
delete list;

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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