急!如何遍历一个窗体内的全部控件或对象?

Qcj 2000-04-26 06:02:00
如何遍历一个窗体内的全部控件或对象?delphi有没有类似vb中的for each ... in 的语句?
delphi有没有类似vb中的iif()函数或c语言中的? :三目运算符?
...全文
183 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
halfdream 2000-04-28
  • 打赏
  • 举报
回复
遍历所有控件用Controls属性,
遍历所有组件用Components属性。
至于用法txy已经举了例子。
kxy 2000-04-26
  • 打赏
  • 举报
回复
TComponent.ComponentCount


Note: This code does not save the form or data module to disk after the nonvisual components are moved. If executed at runtime, the effect will not persist.

var

I: Integer;
Temp: TComponent;
begin
for I := ComponentCount - 1 downto 0 do
begin
Temp := Components[I];
if not (Temp is TControl) then
begin
RemoveComponent(Temp);
DataModule2.InsertComponent(Temp);
end;
end;
end;
:三目运算符? 没有

5,379

社区成员

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

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