Autor Beitrag
firefuzy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 69

Win 98 SE, WinXP Prof, Vista HPrem.
Delphi 7
BeitragVerfasst: Fr 14.07.06 20:58 
Hallo zusammen!
Ich hab mal ne simple Frage:
Gibt es eine Routine die die Eigenschaften von viele Komponenten der gleichen Klasse ändert?
Wenn ich zum Beispiel 20 Edit.texte auf '' stellen will, würde das ein ewig großer Block geben, wenn ich die alle einzeln ändere. z. B.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
 Edit1.Text:='';
 Edit2.Text:='';
 Edit3.Text:='';
 ...

:roll:

MfG firefuzy
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Fr 14.07.06 21:00 
Du könntest Tipparbeit durch Rechenzeit tauschen ;-)
Schleife mit .FindComponent/.FindControl.

_________________
Markus Kinzler.
firefuzy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 69

Win 98 SE, WinXP Prof, Vista HPrem.
Delphi 7
BeitragVerfasst: Fr 14.07.06 21:05 
Zitat:
Schleife mit .FindComponent/.FindControl.

Etwas ausführlicher bitte - hab ich beides noch nie gehört :D :D :D
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Fr 14.07.06 21:09 
Die Formularklasse kennt die Methoden FindComponent bzw. FindControl mit deren Hilfe man untergeordnete Komponenten/Controls über den Namen finden kann.

z.B. (Form.FindComponent('Edit1') as TEdit).Text := ...;

_________________
Markus Kinzler.
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Fr 14.07.06 21:10 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
var i:integer;

for i := 1 to 20 do
    (FindComponent('edit'+inttostr(i)) as TEdit).text:='';

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
firefuzy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 69

Win 98 SE, WinXP Prof, Vista HPrem.
Delphi 7
BeitragVerfasst: Fr 14.07.06 21:20 
Vielen Dank für die schnelle Hilfe :D :D :D

MfG firefuzy
firefuzy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 69

Win 98 SE, WinXP Prof, Vista HPrem.
Delphi 7
BeitragVerfasst: Fr 14.07.06 22:00 
Ich hab doch noch ne Frage:
Ich hab jetzt versucht das ganze auf Formen anzuwenden, hab da folgende Zeile ertüfftelt:
ausblenden Delphi-Quelltext
1:
(Findcomponent('Form'+inttostr(a)) as  (Findclass('TForm' + inttostr(a)))).ScaleBy(96, 120);					

aber da macht delphi nicht mit (Undeclared indentifier: 'ScaleBy')
Wie geht das mit den Formen?
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Fr 14.07.06 22:05 
Versuchs mal mit
Application.Findcomponent('Form'+inttostr(a) as TForm).ScaleBy(96, 120);

Getippt und nicht getestet.

_________________
Markus Kinzler.
firefuzy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 69

Win 98 SE, WinXP Prof, Vista HPrem.
Delphi 7
BeitragVerfasst: Fr 14.07.06 22:13 
Mit einem Klammernpaar mehr hats funktioniert:
(Application.Findcomponent('Form'+inttostr(a)) as TForm).ScaleBy(96, 120);

Danke :D