1

Using Delphi XE2.

Writing a software package to do with a customer database. I have a form which displays all customer info on it and one of these fields is a lookupcombobox with a button next to it. (The lookupcombobox drops down a list with more than one string)

When opening the form (insert/edit mode) i need the button next to the lookupcombobox to be disabled if nothing is selected in the lookupcombobox else enabled if something is selected.

I'm hoping this will be quite straight forward. I just can't seem to work it out for myself.

TLama
  • 75,147
  • 17
  • 214
  • 392
Sharpie
  • 373
  • 2
  • 15
  • 34

1 Answers1

1

In Delphi's Help:

Vcl.DBCtrls.TDBLookupControl.KeyValue

Represents the common value of the KeyField field and the DataField field.

Use KeyField to determine the value represented by the lookup control (not the value displayed by the lookup control). When KeyValue is set, the lookup control attempts to find a record from the ListSource's dataset where the value of KeyField matches KeyValue. If such a match is found, the lookup control displays the value of ListField on that record.

So when I played with it I could do the following:

  Button1.Enabled := not (DBLookupComboBox1.KeyValue = null);

This was without a DB connected to it so don't know what will happen if there was data in the combobox previously and one of the items were selected before. You will have to test.

Blurry Sterk
  • 1,595
  • 2
  • 9
  • 18