Autor Beitrag
www.pat
Hält's aus hier
Beiträge: 12

WinXP pro
Delphi2005
BeitragVerfasst: Mo 07.08.06 13:16 
Hi!

Ich habe atm folgende Ausgabe für ein Label.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
case  status11 of 0: begin Label11.Font.Color:=clblack;
                           T111:=0;
                           T211:=0;
                     end;
                  1: begin Label11.Font.Color:=clred;
                           T111:=1;
                           T211:=0;
                     end;
                  2: begin Label11.Font.Color:=clfuchsia;
                           T111:=0;
                           T211:=1;
                     end;
                  3: begin Label11.Font.Color:=clblue;
                           T111:=1;
                           T211:=1;
                     end;
                  4: begin Label11.Font.Color:=clgreen;
                           T111:=0;
                           T211:=0;
                     end;
                  end;


Dumm ist nur, dass ich 80 andere Labels haben, mit denen ich genau das Selbe machen muss.
Gibt es eine Möglichkeit, eine Variable einzufügen z.B. label[x]:=...?
Miri
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 657


Delphi 3 Prof., Delphi 2005 PE
BeitragVerfasst: Mo 07.08.06 13:24 
Such mal nach Suche in der Entwickler-Ecke FINDCOMPONENT
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: Mo 07.08.06 13:28 
TLabel(FindComponent('Label'+inttostr(x))).caption := 'ich bin label '+inttostr(x)+'!';;)
www.pat Threadstarter
Hält's aus hier
Beiträge: 12

WinXP pro
Delphi2005
BeitragVerfasst: Mo 07.08.06 18:29 
Wow Danke!!
www.pat Threadstarter
Hält's aus hier
Beiträge: 12

WinXP pro
Delphi2005
BeitragVerfasst: Mo 07.08.06 19:52 
Hi!

Das mit den Labels klappt wunderbar.
Praktischerweise hab ich meine Variablen (Integer) so benannt, dass sie auf Label11-label80 passen,
nämlich T111-T180
und T211-T280.
We schaffe ich es den Variablennamen hinzukriegen?
Ich habe etwas von FindVariable gelesen, aber das scheint es nicht zu geben.


ausblenden Delphi-Quelltext
1:
2:
3:
TLabel(Form1.FindComponent('Label'+IntToStr(x)+'.Font.color')).Font.Color :=clblack; //funktioniert
FindVariable('T1'+IntToStr(x)) :=1; //funkt nicht
FindVariable('T2'+IntToStr(x)) :=0;
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mo 07.08.06 19:55 
Es gibt diese Funktion (Findvariable) auch nicht. Verwende besser einen Array um sowohl die lables, wie auch die Integer abzulegen.

_________________
Markus Kinzler.
www.pat Threadstarter
Hält's aus hier
Beiträge: 12

WinXP pro
Delphi2005
BeitragVerfasst: Mo 07.08.06 20:33 
Du bist genial! Das löst mehr Probleme als ich in diesem Threat ausgeführt hab. Danke!