初学遇到的基础问题,谁知道?(20分)

L

LEEMA

Unregistered / Unconfirmed
GUEST, unregistred user!
假如我要给100个Label赋值,该怎样做?
这100个Label的Name依次是Label1,Label2...Label100。
让Label1.Caption := '1' ;
Label2.Caption := '2' ;
...
Label100.Caption := '100' ;
如果是100个Image又该怎样做?
 
用控件数组啊!
然后再用循环赋值:
for i:=1 to 100do

begin
label.caption := inttostr(i) ;
end ;
 
for i:=1 to 100do
TLabel(FindComponent('Label'+IntToStr(i))).Caption:=IntToStr(i)
Image照抄.
 
var
comp : TComponent;
for I := 1 to 100do
begin
comp := FindComponent('Label'+IntToStr(I));
if Assigned(Comp) then
TLabel(Comp).Caption := IntTOSTr(I);
end;
image的道理是一样的
 
多谢了,分少只好将就了:D
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
507
import
I
D
回复
0
查看
919
DelphiTeacher的专栏
D
顶部