Autor Beitrag
JoelH
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 806
Erhaltene Danke: 17

Win10
Delphi Alexandria 11.2 Patch 1
BeitragVerfasst: Do 23.10.03 07:56 
Warum löscht der erste Codeteil zwar die Editfelder der zweite füllt sie aber nicht ?

Text1 und Text2 sind belegt mit Daaten das ist sicher trotzdem bleiben die Editfelder leer
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure Tfrm_dlg_vwkstaffellerzeugen.cmd_leerenClick(Sender: TObject);
var i : integer;
begin
 i := 1;
  while (i <= 21) do
  begin
    TEdit(FindComponent('Edit'+IntToStr(i))).Text := '';
    TEdit(FindComponent('Edit'+IntToStr(i+22))).Text := '';
    inc(i);
  end;
end;


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
     i := 1;
      while not(eof) do
      begin
        text1 := FieldByName('bis').asString;
        Text2 := FieldByName('betrag').asString;
        TEdit(FindComponent('Edit'+IntToStr(i))).Text := text1;
        TEdit(FindComponent('Edit'+IntToStr(i+22))).Text := text2;
        next;
        inc(i);
      end;


Moderiert von user profile iconTino: Code- durch Delphi-Tags ersetzt.

_________________
mfg. Joel
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Do 23.10.03 09:53 
Hallo!

Kann es sein das die Anweisungen in der While-Schleife nicht ein einziges Mal ausgeführt werden? Überprüfe mal die Angabe not(eof).

Gruß
Tino
JoelH Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 806
Erhaltene Danke: 17

Win10
Delphi Alexandria 11.2 Patch 1
BeitragVerfasst: Do 23.10.03 11:18 
Titel: hmm,
nein. text1 und text2 werden gefüllt, hab ich via debugger getestet, die Schleife wird dreimal durchlaufen und die Daten aus der DB stimmen und sind vorhanden. Es tritt auch kein fehler auf, nur die Editfelder der Form bleiben leer :(

_________________
mfg. Joel
mirage228
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 338

Win 7 Prof.
Delphi 2005 Prof., Delphi 2010 Prof.
BeitragVerfasst: Do 23.10.03 11:23 
versuch doch mal anstatt der zuweisung an 'text', die methode SetTextBuf(PChar(text1));

mfG
mirage228

p.s.: du könntest auch versuchen ein 'update' auf die edit-felder auszuführen...

_________________
May the source be with you, stranger.
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Do 23.10.03 11:25 
Werden die Editfelder auch wirklich gefunden? Versuch mal folgendes:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
Var
  Edit: TComponent;

  {...}

  Edit := FindComponent ('Edit' + IntToStr (i));
  If Assigned (Edit) and (Edit is tEdit) Then
    TEdit (Edit).Text := Text1;

  Edit := FindComponent ('Edit' + IntToStr (i+22));
  If Assigned (Edit) and (Edit is tEdit) Then
    TEdit (Edit).Text := Text2;

Prüf mal ob die Zuweisung durchgeführt wird.

Gruß
Tino
JoelH Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 806
Erhaltene Danke: 17

Win10
Delphi Alexandria 11.2 Patch 1
BeitragVerfasst: Do 23.10.03 13:01 
Titel: hmm,
@Tino
Edit := FindComponent ('Edit' + IntToStr (i));

geht nicht, der linken Seite darf nichts zugeordnet werden.


Ich hab jetzt aber den Fehler gefunden. Um die ganzen zweite Schleife lag ein with das hab ich rausgenommen und jetzt geht es, weiss jemand warum ? das with war für eine TQuery Komponenten, naja und die hat doch keine Edit Methode, oder ?was wird da missinterpretiert ?

_________________
mfg. Joel
mirage228
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 338

Win 7 Prof.
Delphi 2005 Prof., Delphi 2010 Prof.
BeitragVerfasst: Do 23.10.03 13:09 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
with Query1 do
begin
  (FindComponent('Edit1') as TEdit).Text := '....irgendwas...';
end;


bewirkt, dass nicht im Form nach dem Edit gesucht wird, sondern bei Query1 (soweit ich das ganze verstanden habe)

_________________
May the source be with you, stranger.
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Do 23.10.03 15:26 
Titel: Re: hmm,
JoelH hat folgendes geschrieben:
geht nicht, der linken Seite darf nichts zugeordnet werden.

Bei mir funktioniert es.

mirage228 hat folgendes geschrieben:
bewirkt, dass nicht im Form nach dem Edit gesucht wird, sondern bei Query1 (soweit ich das ganze verstanden habe)

So etwas in der Art hatte ich mir auch gedacht. Deshalb hab ich ja gesagt er soll prüfen ob FindComponent überhaupt die Komponenten findet.

Gruß
Tino
JoelH Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 806
Erhaltene Danke: 17

Win10
Delphi Alexandria 11.2 Patch 1
BeitragVerfasst: Do 23.10.03 17:33 
Titel: hmm,
wieder was gelernt, dank euch.

_________________
mfg. Joel