Autor Beitrag
chickenfigt1989
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 444
Erhaltene Danke: 2



BeitragVerfasst: So 10.04.11 23:57 
Hallom
Bei meinen Kontaktformular wenn ein Editfeld leer ist sollte dies rot markiert sein.
Wenn eins leer ist und man auf Absenden klickt kommt eine Showmessage
Aber wie mach ich das, dass es das Feld das leer ist einfärbt?
Mein Code:
ausblenden Delphi-Quelltext
1:
2:
3:
  if (Edit1.text=''or (Edit2.text=''or (Edit3.text=''then
  begin
  Showmessage('Keine Eingabe');


lg
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 11.04.11 00:02 
Wie wäre es wenn du die eigenschaft color von TEdit verwendest. Und dann noch ne if-abfrage und fertig.

lg elundril

Und weil du du bist bekommst du noch die üblichen links damit du endlich mal lernst das du mal was lesen solltest.
Delphi-Wikibook
Christians Crashkurs

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
chickenfigt1989 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 444
Erhaltene Danke: 2



BeitragVerfasst: Mo 11.04.11 00:09 
Habs jetzt so gelöst:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
if (Edit1.text=''or (Edit2.text=''or (Edit3.text=''then
  begin
  Showmessage('Keine Eingabe');
  if Edit1.text='' then
  begin
  Edit1.color:=clRed;
  end;
  if Edit2.text='' then
  begin
  Edit2.color:=clRed;
  end ;
  if Edit3.text='' then
  begin
  Edit3.color:=clRed;
  end;

lg
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 11.04.11 00:52 
Erkläre mir mal bitte warum du noch mal die if-Abfragen innerhalb der if-Abfrage hast.
chickenfigt1989 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 444
Erhaltene Danke: 2



BeitragVerfasst: Mo 11.04.11 00:57 
Wie soll ich sonst machen das das Feld das leer ist eingefärbt wird?
lg
Hobby-Programmierer
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 238
Erhaltene Danke: 4

Win XP Pro, Vista Ultimate Trial :o)
D6 Pro, D7 Pro, Turbo, XE SE
BeitragVerfasst: Mo 11.04.11 01:02 
... einmal Rot immer Rot!
Villeicht solltest du gleich alle Edits Rot färben und erst bei ner Eingabe die Farbe auf Normal ändern.


Zuletzt bearbeitet von Hobby-Programmierer am Mo 11.04.11 01:04, insgesamt 1-mal bearbeitet
chickenfigt1989 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 444
Erhaltene Danke: 2



BeitragVerfasst: Mo 11.04.11 01:04 
Was meinst du mit einmal Rot immer Rot?
Hobby-Programmierer
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 238
Erhaltene Danke: 4

Win XP Pro, Vista Ultimate Trial :o)
D6 Pro, D7 Pro, Turbo, XE SE
BeitragVerfasst: Mo 11.04.11 01:06 
Du änderst die Farbe bei nem Fehler, was ist wenn der Fehler korrigiert wurde?
chickenfigt1989 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 444
Erhaltene Danke: 2



BeitragVerfasst: Mo 11.04.11 01:20 
Bei den Onchange Ereignis des Edit Feldes
wird die farbe mittels:
ausblenden Delphi-Quelltext
1:
Edit1.color:=clWindow;					

zurückgesetzt
lg
Hobby-Programmierer
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 238
Erhaltene Danke: 4

Win XP Pro, Vista Ultimate Trial :o)
D6 Pro, D7 Pro, Turbo, XE SE
BeitragVerfasst: Mo 11.04.11 01:32 
Dann mach es doch gleich anständig!
1. alle Eingabefelder beim Start mit Rot färben oder im OI umstellen, Absende-Button auf false :wink:
2. ...
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.AllEditChange(Sender: TObject);
begin
  with (Sender as TEdit) do begin
    if Trim(Text) = '' then
      Color:= clRed
     else
      Color:= clWindow;
  end;

  btn_Absenden.Enabled:= not ((Edit1.Color= clRed) or (Edit2.Color= clRed) or (Edit3.Color= clRed);

end;