Autor Beitrag
GericasS
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 540

Windows Vista Home Premium
D2010, VisualStudio2008
BeitragVerfasst: Mo 24.09.07 13:32 
Hey,

ich hab in meinem Programm momentan 5 edit feldern und möchte per onclick button die Inhalte löschen. Mir ist zwar bewusst das es wie folgt funktioniert :

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.Button1Click(Sender: TObject);
begin
edit1.text := '' ;
edit2.text := '' ;
....


aber das sieht nicht so gut aus, kann ich das nicht über ein array machen indem ich mit einem Befehl mehrere auf einmal ansprechen kann und das nur mit einem Befehl ?

GericasS :D

_________________
Alexander N.
Neue Bewaffnung Amilo xi2428 T9300
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 24.09.07 13:48 
Moin!

Du suchst Suche in: Delphi-Forum, Delphi-Library FINDCOMPONENT. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
GericasS Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 540

Windows Vista Home Premium
D2010, VisualStudio2008
BeitragVerfasst: Mo 24.09.07 13:59 
hey vielen dank

ich hab folgendes gefunden

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
      for i := 0 to Self.ComponentCount - 1 do
          if (Self.Components[i] is TEdit) then
            begin
              TEdit(Self.Components[i]).Clear;
            end;


könntest du mir vll. den quellcode genauer erläuten, weil einfach nur copy und paste find ich nicht so gut !

_________________
Alexander N.
Neue Bewaffnung Amilo xi2428 T9300
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 24.09.07 14:24 
Moin!

user profile iconGericasS hat folgendes geschrieben:
könntest du mir vll. den quellcode genauer erläuten, weil einfach nur copy und paste find ich nicht so gut !

Klar, gerne: ;)
ausblenden Delphi-Quelltext
1:
2:
3:
for i := 0 to Self.ComponentCount - 1 do // durchsuche alle Komponenten des aktuellen Formulars
  if (Self.Components[i] is TEdit) then // wenn es ein TEdit ist, dann...
    TEdit(Self.Components[i]).Clear; // lösche den Inhalt

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Mo 24.09.07 14:36 
braucht man gar kein as zwischen TEdit und (Self.Components[i]).clear; ???

lg elundril
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 24.09.07 14:45 
Moin!

user profile iconelundril hat folgendes geschrieben:
braucht man gar kein as zwischen TEdit und (Self.Components[i]).clear; ?

Nein, das ist ein Typecast TEdit(). :idea: Die as-Variante ginge aber auch. ;)

cu
Narses

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


Zuletzt bearbeitet von Narses am Mo 24.09.07 16:36, insgesamt 1-mal bearbeitet
GericasS Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 540

Windows Vista Home Premium
D2010, VisualStudio2008
BeitragVerfasst: Mo 24.09.07 15:30 
Ich danke dir für die tolle Erläuterung habs verstanden und funktioniert auch super !

:D


Grüße

GericasS

_________________
Alexander N.
Neue Bewaffnung Amilo xi2428 T9300