Autor Beitrag
Caesar44
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 44



BeitragVerfasst: Di 02.06.09 18:45 
So sieht momentan mein Quelllcode, um 64 Felder zu bemalen.
Leider viel Schreibarbeit.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
case Feld[11of
   0 : Label11.color:= clWhite;
   1 : Label11.color:= clBlack;
   2 : Label11.color:= clRed;
 end;
 case Feld[12of
   0 : Label12.color:= clWhite;
   1 : Label12.color:= clBlack;
   2 : Label12.color:= clRed;
 end;


Wie kann ich die einzelnen Labels mit einer Zählvariable k ansprechen, das ich die Anweisung nur einmal schreiben muss und die Zahlen durch k ersetzen kann?

Viele Grüße Caesar
Tropby
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 71
Erhaltene Danke: 4

Vista, Win XP, Win 89
Turbo Delphi Ex.
BeitragVerfasst: Di 02.06.09 18:59 
Du kannst dir die Labels in ein Array legen :

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var LabelArray : array [1..64of TLabel;
{...}

LabelArray[1] := Label11;

LabelArray[1].color := clwhile;


Nun sollte das Label weiß sein.

MfG
Tropby
Caesar44 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 44



BeitragVerfasst: Di 02.06.09 19:30 
Vielen Dank! Super Leute und Forum :-)
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10184
Erhaltene Danke: 1259

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 02.06.09 20:09 
Moin!

user profile iconCaesar44 hat folgendes geschrieben Zum zitierten Posting springen:
Wie kann ich die einzelnen Labels mit einer Zählvariable k ansprechen, das ich die Anweisung nur einmal schreiben muss und die Zahlen durch k ersetzen kann?
Alternativ gibt es noch die Variante über Suche in: Delphi-Forum, Delphi-Library FINDCOMPONENT oder das .Components[]-Array der Form. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.