The task is firemonkey, it’s necessary that the data of one column are output to the combobox via livebindings, it’s simple, but there are no correct descriptions of this thing. Found a solution to this problem, I need help in translating this link TDBLookupCombobox FireMonkey .

  • Something tells me that they will start minusing you now ... - Gorets
  • And why is that? Try to do it in delphi xe2 and in the firemonkey project. In the old versions of delphi there were no problems, but now everything is via livebindings. Moreover, binding via livebindings is different from VCL. - Serg00000 10:10
  • are you proposing to do this to me? =) where is your question? what's wrong with you? What did you do? or did you just share the information that there are no descriptions for this item? thanks, write better on twitter ... - Gorets
  • I put adoconnection on the form, datasource, bindscopedb connected them, put the combobox, created livebindings for it, control pointed out the combobox, source indicated bindscopedb1, because Since the link was dblink, then a link appeared in bindingslist where the control expression is selectedtext (self) and the source expression is displaytext. When launched, it opens the combobox, and the number of entries in it corresponds to the number in the database, but does not display text, only empty lines. - Serg00000 10:39 pm
  • @Gorets I would have you, yes, it’s a pity. @ Serg00000 try searching for firemonkey information on [this] [1] resource. [1]: - teANYCH

2 answers 2

translation of the article (literal, not prom. Some words did not translate, because it is not necessary). ControlExpressions can be understood as the values ​​that we have as a result, and SourceExpressions are the initial values ​​that we squeeze from the tables.

I do not know if there is a better instruction here, but here’s how I do it:

Suppose you have Table1 and a foreign key to Table2.

  • Make the search field in Table1 with an external key
  • Use TBindList to populate the Text property of the ComboBox component from the required field in Table 2, and fill the Tag property with the main key of Table 2
  • Use TBindPosition to compare the selected text with the search field and Selected.Tag with the foreign key to Table1

Check the SourceComponent property of your TBindList and TBindPosition .
The TBindList must point to the BindScopeDB of Table2.
TBindPosition instead of BindScopeDB Table1.

ControlComponent should point to your TComboBox

When you use TBindList , the generated recordset refers to the same object inside the ComboBox , because each row of Table2 is run through for filling. Therefore, for ControlExpressions you need properties: Text and Tag .
Note : You do not need the Selected property.

and this is SourceExpressions:

FieldByName(LookedUpField).AsString, FieldByName(PK).AsInteger 

Add these expressions to the set of records to be created.

TBindPosition always refers to the entire set of ComboBox objects, so you need to use the Selected property.


 Selected.Tag SelectedText(Self) 


 FieldByName(FK).AsInteger, FieldByName(LookupField).AsString 

Remember that the PosSource set is used for the assignments "ControlExpressions to SourceExpressions" when PosControl contains the assignments "SourceExpressions to ControlExpressions".

Initially, you need two things: change the selected object when the position in Table 1 changes and force your FK (I do not know what it is) to use the Tag property of the selected object when the user changes it.

So just put this in your PosControl kit .

 SelectedText(Self) FieldByName(LookupField).AsString 

And it will be in your set PosSource

 Selected.Tag FieldByName(FK).AsInteger 

If you want to get similar behavior of the TDBLookupComboBox component , you need to set the Table to the editing state when the selected object is changed in the combo box.

and the key phrase:
For more informations look for the examples included with XE2.

  • Thanks for the translation! Anyway, somewhere is wrong, the combo opens, but does not display data, only empty fields. - Serg00000

It is necessary to use BindList and if you need to change the position of the cursor in the DataSet still BindPosition.

  1. In BindList we double-click on it, go to Format in Control Self.Text, in Source AsString. In the BindList itself we specify the name of the control and the name of the source and the field where to get the data for filling.
  2. In BindPosition we poke twice, go in PosControl - in Control - ItemIndex, in Source - RecNo-1; in PosSource - in Control - ItemIndex + 1; in Source - RecNo; and last PosClear - in Control - ItemIndex, in Source - -1.