超级菜的问题:减少代码书写..比如我要写很多 Form1.edit1.text:='111'

prettysky 2003-09-08 03:19:48
减少代码书写..比如我要写很多

Form1.edit1.text:='111' ;
Form1.edit2.text:='111' ;
Form1.edit3.text:='111' ;
Form1.edit4.text:='111' ;
Form1.edit5.text:='111' ;
Form1.edit6.text:='111' ;
Form1.edit7.text:='111' ;
Form1.edit8.text:='111' ;

能不能用

edit1.text:='111' ;
edit2.text:='111' ;
edit3.text:='111' ;
edit4.text:='111' ;
edit5.text:='111' ;
edit6.text:='111' ;
edit7.text:='111' ;
edit8.text:='111' ;

来代替?

记得VB里面有一个函数能够实现
...全文
32 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
prettysky 2003-09-09
  • 打赏
  • 举报
回复
谢谢大家...马上结帖
georgehappy 2003-09-08
  • 打赏
  • 举报
回复
遍历FORM上的所有控件,只要是TEDIT就给它赋‘111’就行了三
Linux2001 2003-09-08
  • 打赏
  • 举报
回复
自己搜索一下以前的帖子,问过无数遍了
IORILI 2003-09-08
  • 打赏
  • 举报
回复
如果edit1等在form1中,那么就不用在控件的前面加form1了 如果是在别的窗体中写的话
这样写;
with form1 do
begin

edit1.text:='111'
...
end;

with form1 do
for i:=1 to n do
with TEdit(FindComponent('Edit'+inttostr(i))) do
text:='111' ;
也可以
dulei115 2003-09-08
  • 打赏
  • 举报
回复
with form1 do
for i:=1 to n do
with TEdit(FindComponent('Edit'+inttostr(i))) do
text:='111' ;

Dephiuser 2003-09-08
  • 打赏
  • 举报
回复
var
editln:array [1..10] of TEdit;
i:integer;
for i:=1 to 10 do
begin
editln[i]:=TEdit(findcomponent('edit'+inttostr(i));
editln[i].text:='lll';
end;
Littleming 2003-09-08
  • 打赏
  • 举报
回复
‘var i:integer;’要写在紧跟 procedure 语句之后
Littleming 2003-09-08
  • 打赏
  • 举报
回复
给edit1->edit8设tag属性为2
var i:integer
for i:=1 to component-1 do
begin
if components[i] is Tedit then
if (components[i] as TEdit).tag=2 then
(components[i] as Tedit).Text:='lll';
end;
lzybfs 2003-09-08
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/topic/2233/2233772.xml?temp=.3362543
漠北刀客 2003-09-08
  • 打赏
  • 举报
回复
如果From与Edit控件在一个单元内那么
edit1.text:='111' ;
edit2.text:='111' ;
edit3.text:='111' ;
edit4.text:='111' ;
edit5.text:='111' ;
edit6.text:='111' ;
edit7.text:='111' ;
edit8.text:='111' ;
若不在一个单元内,则可以
with Form1
edit1.text:='111' ;
edit2.text:='111' ;
edit3.text:='111' ;
edit4.text:='111' ;
edit5.text:='111' ;
edit6.text:='111' ;
edit7.text:='111' ;
edit8.text:='111' ;
end;

5,928

社区成员

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

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