如何遍历组件(非数组形式)

phafer 2003-08-14 02:59:33
有一个TStrings
和结果TEdit
想用一个循环为这些TEdit赋值,可能么?怎么做?

...全文
32 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
pressman 2003-08-14
  • 打赏
  • 举报
回复
有一个TStrings
和结果TEdit
想用一个循环为这些TEdit赋值??
问题描述得不太清楚哦!
你的代码已经篇历了组件了哦!
你要向TEDIT中赋什么值呢?
请详细点。
things 2003-08-14
  • 打赏
  • 举报
回复
procedure TForm1.Button1Click(Sender: TObject);
var
i, j : integer;
strList : TStringList;
begin
strList := TStringList.Create;
strList.Add('aaaaaaa');
strList.Add('bbbbbbb');
strList.Add('ccccccc');
strList.Add('ddddddd');
j := 0;
for i := 0 to Self.ComponentCount -1 do
begin
if Self.Components[i] is TEdit then
begin
TEdit(Self.Components[i]).Text := strList.Strings[j];
j := j + 1;
end;
end;
strList.Free;
end;
phafer 2003-08-14
  • 打赏
  • 举报
回复
应该自己搜索一下先的,太懒了。。。
第一个回文的,分数都拿去。
procedure TForm1.Button1Click(Sender: TObject);
var
i : Integer;
begin
for i := 0 to Form1.ControlCount-1 do
begin
if Form1.Controls[i] is TEdit then
ShowMessage( Form1.Controls[i].Name );
end;
end;

5,388

社区成员

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

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