Autor Beitrag
DennisSpohr
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Di 02.01.07 13:40 
Hallo,

ich habe folgendes Problem:
ich habe ganz viele Labels:
i1,i2,i3,i4...
kann ich diese genauso wie Varibalen wie ein array benutzen??
sowas wie label[i].caption := 'hallo';

Danke für eure Hilfe! ;-)

Dennis
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Di 02.01.07 13:44 
Zwei Möglichkeiten: Du nimmst ein Array of TLabel und packst im FormCreate einmal alle Label in das Array ein. Oder du nimmst Suche in: Delphi-Forum, Delphi-Library FINDCOMPONENT.

_________________
We are, we were and will not be.
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Di 02.01.07 15:41 
Hallo,

die dritte Möglichkeit:
Man packt alle Labels auf ein Panel und kann dann mittels Controls/ControlCount darauf zugreifen:
ausblenden Delphi-Quelltext
1:
showmessage(TLabel(Panel1.Controls[0]).Caption);					

Ich finde diese Lösung besser, denn FindComponent durchläuft für jedes gesuchte Label die ControlListe der Form.

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )