Autor Beitrag
Jerk
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 251

Vista Ultimate, Ubuntu
Turbo Delphi 2006
BeitragVerfasst: Sa 29.09.07 17:14 
Was ich vorhabe ist das ich z.b. 30 Labels habe und ich möchte alle bei einem bestimmten ereignis den Text ändern lassen, nun dachte ich mir ich mach es einfach so:
ausblenden Delphi-Quelltext
1:
 for i:= 1 to 30 do label[i].caption:'bblabla';					


Das klappt halt nicht :p
ich kann mich auch dunkel dran erinnern das das irgentwie mit Findcomponent() ging.

Ich weis auch das es zu der geschichte nen how to gibt, llerdings weis ich die Suchbegriffe dafür nicht bzw ich bin schlichtweg zu doof oder so -.-

Naja Danke schonmal im vorraus.
Jann1k
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 866
Erhaltene Danke: 43

Win 7
TurboDelphi, Visual Studio 2010
BeitragVerfasst: Sa 29.09.07 17:22 
suchbegriff findcomponent wäre schonmal nicht schlecht. Wenn deine labels label1,label2..label29,label30 heißen, dann geht das so:

ausblenden Delphi-Quelltext
1:
2:
  for i:= 1 to 30 do 
  TLabel(findcomponent('label'+inttostr(I))).caption:='HalliHallo'
Mike19
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 256

Win XP, Vista, Win 7
Delphi 2005, Turbo Delphi
BeitragVerfasst: Sa 29.09.07 17:22 
Hallo,

aber mit Deiner For .. Anweisung gibst Du 30 Label das gleiche Caption ?
IceBube
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 231



BeitragVerfasst: Sa 29.09.07 17:23 
...auch ne möglichkeit...

ausblenden Delphi-Quelltext
1:
2:
3:
4:
for i:= 0 to Form1.ComponentCount-1 do
begin
if Form1.Components[i].ClassType = TLabel then (Form1.Components[i] as TLabel).Caption := '333';
end;


lg
Mike19
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 256

Win XP, Vista, Win 7
Delphi 2005, Turbo Delphi
BeitragVerfasst: Sa 29.09.07 17:42 
Das versteh nun nicht mehr,

ich denke Du willst zu Caption abhängig von einem Ereignis einen bestimmten Label[1..30] zuweisen ?
Jerk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 251

Vista Ultimate, Ubuntu
Turbo Delphi 2006
BeitragVerfasst: Sa 29.09.07 18:07 
Es ging mir halt darum das mit dem Index zu realisieren, ob man jetzt ne Zählerschleife oder was anderes drum rum baut ist halt vom Fall abhängig.

Vielen dank aufjedenfall :)
Mike19
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 256

Win XP, Vista, Win 7
Delphi 2005, Turbo Delphi
BeitragVerfasst: Sa 29.09.07 18:20 
Hallo,
Zitat:

Was ich vorhabe ist das ich z.b. 30 Labels habe und ich möchte alle bei einem bestimmten ereignis den Text ändern lassen, nun dachte ich mir ich mach es einfach so:


Entschuldigung, ich habs so verstanden, dass nach einer bestimmten Abfrage einem bistimmten Label ein Captionwert zugewiesen wird.