2017-11-10 5 views

Antwort

0

Am einfachsten wäre ein Konstrukt wie diese

if (ComboBox1.ItemIndex = -1) or (ComboBox2.ItemIndex = -1) or (ComboBox3.ItemIndex = -1) then 
    Exit; 

Button1.Enabled := true; 

sein Dieses das Verfahren beendet, wenn eine der Comboboxen -1 ausgewählt hat. Wenn alle Felder ausgewählt sind, wird die Schaltfläche aktiviert.

Oder Sie könnten nur sie binden alle zusammen und schreiben Sie direkt auf die Eigenschaft Enabled

Button1.Enabled := (ComboBox1.ItemIndex <> -1) and (ComboBox2.ItemIndex <> -1) and (ComboBox3.ItemIndex <> -1); 

Die schönste Art und Weise, wenn Sie wirklich eine Menge Comboboxen haben wird Arrays

procedure TForm1.SetButtonActive; 
var 
    boxes: array of TComboBox; 
    box: TComboBox; 
begin 
    boxes := [ComboBox1, ComboBox2, ComboBox3]; 

    for box in boxes do 
     if box.ItemIndex = -1 then 
      Exit; 

    Button1.Enabled := true; 
end; 
Verwandte Themen