I’m not sure I understand.
ItemIndex is the index of the row in the dropdown list. The active row or selected row is indicated by DBAdvSearchEdit.ItemIndex
I have one DBAdvSearchEdit component connected to a customer listsource.
This listsource has two fields (customer_name and customer_id)
In the DBAdvSearchEdit, I have created two TColumnItems for each field:
TColumnItems[0] for the customer_name and TColumnItems[1] for the customer_id
When the user choose a customer in the list, I want to retrieve the customer_id from TColumnItems[1] ?
(DBAdvSearchEdit.Datasource and DBAdvSearchEdit.Datafield are empty for this case.)
From the OnSelect event, you could have an event handler like:
procedure TForm1.DBAdvSearchEdit1Select(Sender: TObject); var id: string; begin id := DBAdvSearchEdit1.Items[DBAdvSearchEdit1.ItemIndex].Captions[CustomerIDColumn]; end;
I wrote something wrong in my explanation of my morning post !
Here is the good text:
Is it possible to link to another table "order_table" which has the “customer_id” identifier ?
With the same settings as before, I add on the DBAdvSearchEdit component :
datasource:=order_source;
datafield:=DBAdvSearchEdit1.DataField := TDBColumnItem(DBAdvSearchEdit1.Columns[1]).DataField ;
Now, when I navigate in the "order_table" , i can see the customer_id changing.
But I see the identifier “customer_id”, not the customer_name in the component ?
Maybe , something I don’t understand ?
I want the same behaviour of the TAdvDBLookupComboBox.
There is at this moment not a similar link via a KeyField in TDBAdvSearchEdit like there is in TAdvDBLookupComboBox
The DBAdvSearchEdit.ListSource is used to fill the search list and the DataSource is used to link the text value in the DBAdvSearchEdit to a dataset