Autor Beitrag
Herbert61
Hält's aus hier
Beiträge: 2

Vista, Xp

BeitragVerfasst: Mi 01.09.10 13:39 
Hallo Jungs

ich habe viele Label's in meinem Program und möchte die Label.caption durch eine Schleife ändern.
ist das möglich und wenn ja dann wie ?

beispiel :
ausblenden Delphi-Quelltext
1:
for i:= 1 to 10 do label[i].caption:=array[i].name;					

vielen Dank schon mal im voraus !!

Moderiert von user profile iconNarses: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am Mi 01.09.2010 um 14:40
Moderiert von user profile iconNarses: Delphi-Tags hinzugefügt
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 01.09.10 13:41 
Moin und :welcome: im Forum!

Du suchst Suche in: Delphi-Forum, Delphi-Library FINDCOMPONENT. :lupe: :les: :think: ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Pepp3r
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 82



BeitragVerfasst: Mi 15.09.10 15:03 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var
 i: Word;
begin
 i := 0;
 while (TLabel(FindComponent('label'+inttostr(i)) <> nil) do
 begin
  TLabel(FindComponent('label'+inttostr(i)).Caption := 'blablabla';
  inc(i);
 end;
end;


etwa so.
oder wenn du weißt wieviel Labels du hast, dann eben eine for-schleife

achte also darauf, dass die labels immer noch einem bestimmten schema benannt sind, oder tag dem entsprechend (Label1.tag := 0 etc...)