[Overview][Constants][Types][Classes][Procedures and functions][Index] | Reference for unit 'DBCtrls' (#lcl)

# TDBLookupListBox.DataChange

Performs actions needed when a new DataField value is selected using the lookup dataset.

## Declaration

Source position: dbctrls.pp line 483

`protected procedure TDBLookupListBox.DataChange(`
`Sender: TObject`
`); override;`

## Description

DataChange is an overridden method in TDBLookupListBox. It implements the abstract virtual method defined in the ancestor class, and provides support for setting the value in ItemIndex when the value for KeyField in the lookup dataset has changed.

DataChange uses the internal TFieldDataLink instance in the control to determine if the linked dataset has been opened. If the dataset is active, the value in ItemIndex is set to the key index position from the lookup dataset. If the linked dataset is not active, the value in ItemIndex is set to -1 (indicating no item is selected in the control).

DataChange is used as the OnDataChange event handler for the internal TFieldDataLink instance in the control, and called from the DoSelectionChange method.

## See also

TDBLookupListBox.DataField |  | Name for the field in the linked dataset used in the control.
TDBLookupListBox.KeyField |  | Field name in the lookup dataset with the value for the control.
TDBLookup.KeyFieldValue |  | Gets the value(s) for one or more key fields defined for the Field in the linked dataset.
TDBLookup.GetKeyIndex |  | Gets the ordinal position in the list for the specified key value.
TCustomDBListBox.DataChange |  | Performs actions needed when the linked dataset is repositioned.
TFieldDataLink.OnDataChange |  | Event handler signalled when the field data link has been changed.
TCustomListBox.ItemIndex |  | Ordinal position for the currently selected item, -1 if none.