Autor Beitrag
willy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27

WinXP Pro (SP2), Suse9.3 Pro, Debian6

BeitragVerfasst: Mo 01.05.06 10:03 
Hallo,
ich habe ein Problem und möchte mich shcon im Vorraus über die Simplität meiner Frage entschuldigen.
Am Anfang muss ich sagen, dass ich aus dem PHP komme und dies dort möglich ist:
Wenn ich abhänig von einer Variablen ein Objekt verändern will ohne eine if-Bedinung.
Also zB.
die Variable ist 3 dann möchte ich bei Image3.Visible änern
bei 4 bei Image4....
usw...
ist das möglich?

Schon mal danke
Willy
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 01.05.06 10:06 
das müßte mit .FindComponent gehen.

ausblenden Delphi-Quelltext
1:
(Form.FindComponent('image'+intToStr( nr)) as Image).Visible := True;					

_________________
Markus Kinzler.
willy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27

WinXP Pro (SP2), Suse9.3 Pro, Debian6

BeitragVerfasst: Mo 01.05.06 10:42 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.Button1Click(Sender: TObject);
begin
inc(i);
with (FindComponent('label'+IntToStr(i))) do Visible := false;
end;


Wenn ich das mache um halt 10 Labels verschwinden zu lassen beendet er mir beim ersten Klick das Programm :(
aim65
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 312

Win 9x, Win XP
Delphi 3pro, 7PE
BeitragVerfasst: Mo 01.05.06 11:14 
Du sprichst damit nur die Sichtbarkeit der Form1 an.

Wenn Du mehrere Objekte (Labels) verschwinden lassen willst, probier das mal:
ausblenden Delphi-Quelltext
1:
2:
for i :=LabelNrA to LabelNrB do   //Bereich Deiner Labels
   TLabel(FindComponent('Label'+IntToStr(i))).Hide


(das Gegenstück zu ".Hide" ist ".Show")
willy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27

WinXP Pro (SP2), Suse9.3 Pro, Debian6

BeitragVerfasst: Mo 01.05.06 12:01 
ok danke problem gelöst :)