DBLookupComboBox - How to clear the selected item?

What I was trying to achieve is how to set ItemIndex to -1, as in a regular ComboBox, so that the selected item will be cleared.

There is no ItemIndex element for DBLookupComboBox, and the Text property is read-only. So how to clear the selected item? Please help. Thank you very much in advance.

PS: Closing and reopening DBLookupComboBox-> ListSource DataSet does not help.

+5
source share
4 answers

Two ways:

1) at runtime: DbLookupComboBox.KeyValue: = null;

2) at design time: set the DbLookupComboBox.NullValueKey property to DEL (or any other key that you want to use for a null value at run time)

+2

DBLookupComboBox . , / , / DBLookupComboBox .

+2

you can use

DBLookupComboBox.KeyValue: = -1;
+2
source

if for the first time you set dblokupcombobox KeyField in the property - 'city' // example

if you want to clear the selected item you can use this

procedure TFtreset.BitBtn6Click(Sender: TObject);
begin
  dblookupcombobox2.KeyValue:='city';
end;
0
source

All Articles