Autor Beitrag
fritz_07
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21



BeitragVerfasst: Sa 09.07.16 14:51 
Hallo an alle,

ich habe folgende Aufgabenstellung:

Im Formular befinden sich zwei Editfelder, eine ComboBox und ein Button.
1x LabeledEdit
1x JvDirectoryEdit
1x ComboBox

Der Button soll erst aktiv (enabled) sein,wenn alle 3 Felder Werte enthalten.
Bei JvDirectoryEdit habe ich es mal so ausprobiert:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.JvDirectoryEdit1Change(Sender: TObject);
var pfad : String;
begin
   pfad := JvDirectoryEdit.Directory;
   if pfad = '' then
     Button3.Enabled := false
   else
     Button3.Enabled := true;

end;


Soweit funktioniert alles.

Wenn ich das jetzt für jedes Feld seperat so mache,bekomme ich eine Art Oderverknüpfung.
Benötigen tue ich aber ein Undverküpfung.
Wie kann ich dies in eine Prozedur schreiben???

Gruß fritz
Mathematiker
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2622
Erhaltene Danke: 1447

Win 7, 8.1, 10
Delphi 5, 7, 10.1
BeitragVerfasst: Sa 09.07.16 15:08 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.JvDirectoryEdit1Change(Sender: TObject);
begin
  button3.Enabled := (JvDirectoryEdit1.Directory <> ''and (LabeledEdit1.Text <> ''
                      and (Combobox1.items.index >= 0);
end;

und die JVDirectoryEdit1Change auch bei LabeledEdit1 und der Combobox1 eintragen.

Beste Grüße
Mathematiker

_________________
Töten im Krieg ist nach meiner Auffassung um nichts besser als gewöhnlicher Mord. Albert Einstein


Zuletzt bearbeitet von Mathematiker am Sa 09.07.16 15:12, insgesamt 1-mal bearbeitet
jfheins
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 918
Erhaltene Danke: 158

Win 10
VS 2013, VS2015
BeitragVerfasst: Sa 09.07.16 15:08 
Schreib dir eine Funktion, die entsprechend zu den Eingabefeldern je einen Parameter hat.
Sowas wie "IsValidInputComposition(a, b, c)". Und dann einfach in allen drei Eventhandlern
ausblenden Delphi-Quelltext
1:
2:
3:
pfad := JvDirectoryEdit.Directory;
name := JvLabeledEdit.Text;
Button3.Enabled := IsValidInputComposition(pfad, name, ...);


Dann kannst du in der Funktion beliebig viele Sachen abprüfen und hast in den Evewnthandlern schönen, sprechenden Code.
Frühlingsrolle
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 09.07.16 15:23 
- Nachträglich durch die Entwickler-Ecke gelöscht -
fritz_07 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21



BeitragVerfasst: Mo 11.07.16 21:39 
Hallo,

vielen Dank für die guten Vorschläge.
Das mit der eigenen Funktion und der TActionList werde ich mal ausprobieren.

Gruß fritz