Autor Beitrag
DuNDy
Hält's aus hier
Beiträge: 5


D7 Prof
BeitragVerfasst: Mo 12.09.05 15:18 
Hi,
gibt es eine Möglichkeit ein Label per Index anzusprechen?
Da ich 46 Labels habe, deren Text ich gerne in einer Schleife ändern möchte.
Also nach folgendem Prinzip:

ausblenden Delphi-Quelltext
1:
2:
3:
for x := 1 to 46 do begin
   Label(x).Caption := inttostr(x+46);
end;


Gruß DuNDy

Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt.
Danniolo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 693



BeitragVerfasst: Mo 12.09.05 15:24 
Ich glaub das hier ist sowas in der Art...:

www.delphi-forum.de/topic_43052.html :wink:
DuNDy Threadstarter
Hält's aus hier
Beiträge: 5


D7 Prof
BeitragVerfasst: Mo 12.09.05 15:28 
Mein Problem ist nur, das die Labels nicht zur Laufzeit erzeugt werden sollen, sondern sich bereits in einer Grafik im Entwurfsmodus befinden...
PLuS
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 98

Win XP, Suse Linux 9.0
D5 Standard, D2005 Personal; Perl; PureBasic
BeitragVerfasst: Mo 12.09.05 15:29 
Das müsste gehen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
var Hilf: TLabel;

begin
     for x:=1 to 46 do
     begin
          Hilf:=TLabel(FindComponent('Label'+inttostr(x)));
          Hilf.Caption:=inttostr(x+46);
     end;
end;


MfG
PLuS
DuNDy Threadstarter
Hält's aus hier
Beiträge: 5


D7 Prof
BeitragVerfasst: Mo 12.09.05 15:33 
Danke das war es, so hat es funktioiert :!: