Autor Beitrag
delphijanka
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 151

WinXP
D 2009 Arc., Java, C
BeitragVerfasst: Mo 09.04.07 11:32 
Ich habe zb 100 Edit-Felder auf der Form liegen. Diese habe einheitiche Bezeichnung "edit"+ziffer.

Wie kann ich alle Edit Felder ablesen (editx.text) in einer Schleife, ohne fur jedes Edit-Feld

e1 := edit1.text
e2 := edit2.text
...

zu schreiben?

danke fur die Hilfe.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mo 09.04.07 11:34 
Das geht mit FindComponent:
ausblenden Delphi-Quelltext
1:
e := TEdit(FindComponent('Edit' + IntToStr(i))).Text;					

_________________
We are, we were and will not be.
delphijanka Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 151

WinXP
D 2009 Arc., Java, C
BeitragVerfasst: Mo 09.04.07 11:36 
jo thx, dachte ich mir auch dass es uber diesen Befehl geht.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mo 09.04.07 11:39 
Alternativ kannst du bei Programmstart die ganzen Edits in ein Array of TEdit packen. Das macht dann Sinn, wenn die Zugriffe schneller ablaufen sollen und/oder das ganze sehr oft passiert.

_________________
We are, we were and will not be.
Robert.Wachtel
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 895
Erhaltene Danke: 7

Windows 7 Ultimate x64
D5 Ent, D7 Arch, RAD Studio 2010 Pro, VS 2008
BeitragVerfasst: Mo 09.04.07 11:48 
user profile icondelphijanka hat folgendes geschrieben:
uber alle Editier-Felder iritieren

ROTFL You made my day. :mrgreen: :mrgreen: :mrgreen:
HelgeLange
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 735
Erhaltene Danke: 6

Windows 7
Delphi7 - Delphi XE
BeitragVerfasst: Mo 09.04.07 12:51 
user profile iconGausi hat folgendes geschrieben:
Alternativ kannst du bei Programmstart die ganzen Edits in ein Array of TEdit packen. Das macht dann Sinn, wenn die Zugriffe schneller ablaufen sollen und/oder das ganze sehr oft passiert.


uhm.. warum ? Das macht doch das Form schon :P

ausblenden Delphi-Quelltext
1:
2:
3:
4:
For i := 0 To Self.ComponentCount - 1 Do
  If (Self.Components[i] is TEdit) Then begin
    ... // your code here
  end;

_________________
"Ich bin bekannt für meine Ironie. Aber auf den Gedanken, im Hafen von New York eine Freiheitsstatue zu errichten, wäre selbst ich nicht gekommen." - George Bernhard Shaw
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mo 09.04.07 13:19 
Das ist schon klar, aber wenn man zusätzlich ein eigenes nimmt, dann lassen sich Konstrukte wie  for i := 23 to 42 do MeinEditArray[i].Text := 'Was ist 5*6?'; schneller durchführen. Immer das gesamte Komponenten-Array durchgehen halte ich da für ungut - noch dazu, wenn man evtl. noch ein paar mehr Edits auf der Form hat, die davon unberührt bleiben sollen.

Aber ich denke, das wolltest du mit dem Smilie auch versteckt sagen, oder? :mrgreen:

_________________
We are, we were and will not be.
HelgeLange
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 735
Erhaltene Danke: 6

Windows 7
Delphi7 - Delphi XE
BeitragVerfasst: Mo 09.04.07 13:23 
erm.. nö, wollte ich nicht versteckt mit dem Smiley sagen :P
Weil die Frage war ja, wie er alle TEdit-Felder durchgehen kann

_________________
"Ich bin bekannt für meine Ironie. Aber auf den Gedanken, im Hafen von New York eine Freiheitsstatue zu errichten, wäre selbst ich nicht gekommen." - George Bernhard Shaw
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mo 09.04.07 13:46 
Nagut..ich hab das alle auf die 100 bezogen. Aber wenn solche Zuweisungs-Schleifen öfters vorkommen, und man noch drölftausend andere Komponenten auf der Form hat, dürfte sich meine Variante trotzdem lohnen :D.

_________________
We are, we were and will not be.
HelgeLange
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 735
Erhaltene Danke: 6

Windows 7
Delphi7 - Delphi XE
BeitragVerfasst: Mo 09.04.07 14:21 
dann muss er aber trotzdem die Liste durchgehen, um Deine Liste erstmal zu bauen ;)
Und Du weisst ja, Speicher sparen...
Zur Not kann man die Edits, die man aus der Liste haben will, taggen :)

_________________
"Ich bin bekannt für meine Ironie. Aber auf den Gedanken, im Hafen von New York eine Freiheitsstatue zu errichten, wäre selbst ich nicht gekommen." - George Bernhard Shaw
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mo 09.04.07 14:30 
Ja, aber nur einmal. Daher das "wenn man das oft machen muss". Spart man Zeit, geht das fast immer zu Lasten des Speichers und umgekehrt. Aber das ist ja fast immer so :nixweiss:

Und: Ich denke, dass user profile icondelphijanka gerade denkt: "Man, sind das Spaten. Es läuft doch." :lol:

_________________
We are, we were and will not be.
HelgeLange
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 735
Erhaltene Danke: 6

Windows 7
Delphi7 - Delphi XE
BeitragVerfasst: Mo 09.04.07 14:43 
stimmt auch wieder, speisen wir die anderen einfach mit miderwertigem Code ab, dann haben potentielle Konkurrenz-Programme weniger Chancen gegen unsere produkte :D

_________________
"Ich bin bekannt für meine Ironie. Aber auf den Gedanken, im Hafen von New York eine Freiheitsstatue zu errichten, wäre selbst ich nicht gekommen." - George Bernhard Shaw