Autor Beitrag
cyclone
Hält's aus hier
Beiträge: 13



BeitragVerfasst: Fr 23.08.02 13:57 
wenn ich ein Komponente aus dem programm raus erstelle wie kann ich dann später in anderen proceduren wieder darauf zugreifen?
Beispiel:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
var
Edit: TEdit;
begin
  Edit := TEdit.Create(self);
  Edit.Parent := Form1;
end;


Nur will ich z.b. den Text in der vorher erstellten komponente ändern...
Ich hab schon ausprobier: Edit.Text := 'Hallo!' aber das tut es nicht...

Wie kann ich das realisieren?

Danke im Voraus! ;)
ao
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 145

Win XP Prof.
D7 Ent.
BeitragVerfasst: Fr 23.08.02 14:02 
Hallo cyclone,

du musst deiner Komponente noch einen Namen zuweisen.
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
var 
Edit: TEdit; 
begin 
  Edit := TEdit.Create(self); 
  Edit.Parent := Form1;
  Edit.Name := 'MeinEdit';
  Edit.Text := ''; //weil sonst standardmäßig "MeinEdit" im Text steht.
end;

Dann kannst du auch aus anderen Prozeduren auf die Komponente zugreifen.MeinEdit.Text := 'Hello World';

Gruß
Andreas
cyclone Threadstarter
Hält's aus hier
Beiträge: 13



BeitragVerfasst: Fr 23.08.02 14:16 
der compiler sagt mir bei:
ausblenden Quelltext
1:
MeinEdit.Text := 'Hallo';					

"Unbekannte Bezeichnung: MeinEdit"...
Aber ich hab das jetzt so gelöst
ausblenden Quelltext
1:
TEdit(FindComponent('MeinEdit')).Text := 'Hallo!';					


Das funzt ist aber ein wenig umständlich ;)
ao
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 145

Win XP Prof.
D7 Ent.
BeitragVerfasst: Fr 23.08.02 14:34 
Stimmt, natürlich muss es so gemacht werden! War ich wohl ein bisschen zu schnell! :oops:

Andreas
Renegade
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 358

Win XP Pro, Win 7 Beta
BDS 2006
BeitragVerfasst: Fr 23.08.02 15:16 
Moin erstmal!

Wenn du das edit global deklarierst, dann kannst du mit
ausblenden Quelltext
1:
Edit.Text:='Hallo';					

auf die Kompo zugreifen.

Gruß Renegade

_________________
Sokrates (468 v.Chr. - 399 v.Chr.)
"Es ist keine Schande, nichts zu wissen, wohl aber, nichts lernen zu wollen."