Frequently Asked Component Specific Questions
Options |
Display all FAQ items |
Displaying items 1 to 1 of 1, page 1 of 1
<< previous next >>
TDBAdvGrid
Lookup other lookup source DB field values when editing with a TAdvDBLookupCombox in TDBAdvGrid
Lookup other lookup source DB field values when editing with a TAdvDBLookupCombox in TDBAdvGrid
When you want to access or use values from other listsource fields used in a TAdvDBLookupComboBox when it is used in a TDBAdvGrid as inplace editor, the appropriate place where to access the dataset field values is from the FormControlEditLink.OnGetEditorValue() event. This event is triggered when the DBAdvGrid is about to be updated with the updated value from the TAdvDBLookupComboBox and thus, at this time, the values for other DB fields in the lookup source can be accessed by accessing the lookup source dataset fields. In the sample, this is done by getting the value for the field ‘Capital’ in the COUNTRY table and storing that field value also in the main TDBAdvGrid in a readonly column.
The code is:
procedure TForm1.FormControlEditLink1GetEditorValue(Sender: TObject; Grid: TAdvStringGrid; var AValue: string); var s:string; begin AValue := AdvDBLookupComboBox1.Text; // get the value from the lookup dataset s := adotable2.FieldByName(''Capital'').AsString; // store the value in the main dataset adotable1.FieldByName(''Capital'').AsString := s; end;
A full sample source application can be downloaded via: https://download.tmssoftware.com/download/advdblookupcomboboxindbadvgrid.zip