动态的填写TEdit---在线等

cryingboy 2005-01-09 02:18:18
在一个form上有n个TEdit
名字为edit1..editn
想写一下个循环填写TEdit.text
如edit1.text='1'...editn.text='n'
?????
...全文
66 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
僵哥 2005-01-09
  • 打赏
  • 举报
回复
var
x:integer;
k:integer;
EditID:string;
IsNumber:Boolean;
begin
for x:=0 to Form1.ComponentCount-1 do
begin
if Form1.Components[x] is TEdit then
begin
EditID:=Form1.Components[x].Name;
EditID:=Copy(EditID,Pos('Edit',EditID)+4,StrLen(PChar(EditID))-Pos('Edit',EditID));
IsNumber:=True;
k:=StrLen(PChar(EditID));
while(K>0) do
begin
if Pos(EditID[k],'0123456789')=0 then IsNumber:=False;
dec( k);
end;
if IsNumber then TEdit(Form1.Components[x]).Text:=EditID;
end;
end;
end;
Kshape 2005-01-09
  • 打赏
  • 举报
回复
//改一下格式
procedure TForm1.SetNull;
var
i:integer;
count:integer;
begin
for i:=0 to self.ComponentCount-1 do
begin
if (self.Components[i] is Tedit) then
begin
count := count+1;
(self.Components[i] as Tedit).Text:=inttostr(count);
end;
end;
end;
Kshape 2005-01-09
  • 打赏
  • 举报
回复
procedure TForm1.SetNull;
var
i:integer;
count:integer;
begin
for i:=0 to self.ComponentCount-1 do
begin
if (self.Components[i] is Tedit) then
begin
count := count+1;
(self.Components[i] as Tedit).Text:=inttostr(count);
end;
end;
end;
王集鹄 2005-01-09
  • 打赏
  • 举报
回复
const
N = 10;
var
I: Integer;
vEdit: TEdit;
begin
for I := 1 to N do
begin
TComponent(vEdit) := FindComponent(Format('Edit%d', [I]));
if vEdit is TEdit then
vEdit.Text := Format('%d', [I])
end;
end;

5,388

社区成员

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

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