TDBAdvSearchEdit

Hello,

I struggle to use the TDBAdvSearchEdit component:

  1. If I add to the component 3 columns for example, what is the code to retrieve the data in column2 of the selected line ?

  2. Is it possible to bind the datasource and datafield to a certain column ? or it’s always the first column by default .

Regards

  1. The value in other columns can be retrieved with:

dbadvsearchedit.Items[itemindex].Captions[columnindex]

  1. The datafield per column can be set with:

dbadvsearchedit.Columns[columnindex].DataField

Hi,

Concerning 1):

Does it mean that for each '“columnindex” ,we need to define an “item.itemindex” ?

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

Hi

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.)

Regards

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;

Hello,

It’s works fine, this is exactly what I wanted to do.

Now, to go further, is it possible to link to another table "order_table" which has the cliend_id identifier ?

With the same settings as before, I add on the DBAdvSearchEdit component :
datasource:=order_source
datafield:=client_id

But it doesn't work because the client_id is in column 1 ?
Is there any possibility to match the table ?

Regards