在一个form上放了10个TEdit控件,怎样把它当作数组操作?

hqhqhw 2002-08-22 12:06:27
我在一个form上面放了10个TEdit控件,我想把它当作数组操作,下面的代码是有错误的,请各位大侠给我修改。
strs:=Tstringlist.create;
for i:=1 to 10
strs.Add(TEdit[i].text);
...全文
18 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
copy_paste 2002-08-22
  • 打赏
  • 举报
回复
private
FEdits: array [0..9] of TEdit;


onCreate;
FEdits[0] := Edit1;
FEdits[1] := Edit2;
...

use
for I ;= 0 to High(FEdits) do
ShowMessage(FEdits[I].Text);
langer1 2002-08-22
  • 打赏
  • 举报
回复
DELPHI里不好用控件姐的,要用就用顶楼的那个方法

for i:=0 to components.count-1 do
begin
if (components[i].is tedit then
begin
tedit(components[i]).setfocus;
^^^^^^^^^^^
end;
end;

hfycl 2002-08-22
  • 打赏
  • 举报
回复
haoco(Lot)和honey_001(小小文) 最理想
chll 2002-08-22
  • 打赏
  • 举报
回复
strs:=Tstringlist.create;
for i:=1 to 10 do
strs.Add(TEdit(FindComponent('Edit'+IntToStr(i))).text);
xzhifei 2002-08-22
  • 打赏
  • 举报
回复
haoco(Lot)和honey_001(小小文) 最理想!!
wetrust 2002-08-22
  • 打赏
  • 举报
回复
可以用动态数组。
rwdx 2002-08-22
  • 打赏
  • 举报
回复
楼上的方法最合适
haoco 2002-08-22
  • 打赏
  • 举报
回复
strs:=Tstringlist.create;
for i:=0 to self.ComponentCount-1 do
if self.Components[i].ClassType=TEdit then
strs.Add(TEdit(Components[i]).Text);
xxyzjf 2002-08-22
  • 打赏
  • 举报
回复
type Edtest=array[0..9]of Tedit;
...
for i:=0 to 9 do
begin
strs.add(edtest[i].text);
end;
以上是创建了一个新类,可以用Honey_001的方法较简单.
honey_001 2002-08-22
  • 打赏
  • 举报
回复
for i:=0 to componentcount-1 do
begin if components[i] is edit then
tedit(components[i]).text:='';


//加分
lwk_hlj 2002-08-22
  • 打赏
  • 举报
回复
用的时候tedit(slist.objects[i]).text:='ddd';
lwk_hlj 2002-08-22
  • 打赏
  • 举报
回复
这样行不?
var
sList:TStrings;
i:integer;
begin
sList:=TStringList.create;

for i:=0 to form1.controls.count-1 do
begin
if form1.controls[i].classtype=tedit then
sList.addobject(Form1.controls[i]ClassName,TEdit(FOrm1.controls[i]));
end;
end;
在用的时候
Tedit(sList.object[1]).text:='ddd';
breezing 2002-08-22
  • 打赏
  • 举报
回复
我用的是copy_paste(木石三) 那种方式,挺好用的,不过我用的是指针

5,388

社区成员

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

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