Autor Beitrag
Kompost
Hält's aus hier
Beiträge: 3



BeitragVerfasst: So 13.05.07 09:39 
Hi, hab da ein kleines Problem wo ich nicht weiterkomme wäre super wenn mir da jemand hilft :)


Ich hab z.B. folgende Label

Label1
Label2
Label3
Label4
Label5

Alle sind unsichtbar. Also bei Form1 steht "Label1.visible := false u.s.w."

Jetzt hab ich aber z.B. ne Variabel i und möchte ein schleife z.B. von i <= 4 laufen lassen und jedes mal das nächste label sichtbar machen. wenn i auf 1 steht also Label1 .... Label4

wie mach ich das dann das ich am beim label nicht immer die zahl hinten dran hänge sondern die variabel ahbs schon mit

Label(i).visible := true;
Label[i].visible := true;

versucht aber das klappt nicht

wäre nett wenn mir jemand helfen könnte :)


Zuletzt bearbeitet von Kompost am Di 15.05.07 11:51, insgesamt 1-mal bearbeitet
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: So 13.05.07 09:47 
Die Forumssuche bringts, die Frage kommt so ungefähr täglich :wink:

Suche in: Delphi-Forum, Delphi-Library FINDCOMPONENT ist das Stichwort.

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
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: So 13.05.07 09:49 
Hallo,

noch ein paar Stichworte:
Controls[x], ControlCount
Components[x], ComponentCount
Array [0..x] of TLabel

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Kompost Threadstarter
Hält's aus hier
Beiträge: 3



BeitragVerfasst: Di 15.05.07 11:56 
Das Problem ist leider immernoch nicht gelöst. Ich habe mir Beiträge im Forum angeschaut und folgende Möglichkeiten ausprobiert:

ausblenden Delphi-Quelltext
1:
2:
Label(Self.Components[i]).caption := chr(wortteile[i]); 
Label(FindComponents[i]).caption := chr(wortteile[i]);


auch was in der delphi hilfe steht bringt einen als absoluten anfänger nicht wirklich weiter

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
procedure TForm1.Button1Click(Sender: TObject);

var
  i: Integer;
const
  NamePrefix = 'MyEdit';
begin
  for i := 1 to 20 do begin
    TEdit.Create(Self).Name := NamePrefix + IntToStr(i);
    with TEdit(FindComponent(NamePrefix + IntToStr(i))) do
    begin
      Left := 10;
      Top := i * 20;
      Parent := self;
    end;
  end;
end;


Wäre nett wenn mir das jemand genauer erklären könnte.
Vielen Dank im vorraus :)

Moderiert von user profile iconUGrohne: Quote- durch Delphi-Tags ersetzt
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Di 15.05.07 11:58 
ausblenden Delphi-Quelltext
1:
TLabel(FindComponent('Label' + IntToStr(I))).Caption := 'Blup';					

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
Kompost Threadstarter
Hält's aus hier
Beiträge: 3



BeitragVerfasst: Di 15.05.07 12:15 
Vielen Dank jetzt klappts :)