0

I use an integer field to store the user's rank: 0=admin, 1=base, ....

In a FMX form I would like to manage this field with a combobox showing the rank string (admin, base, ...).

Is there a way to do this with Live Binding?

orsomannaro
  • 51
  • 1
  • 4
  • Where do you have the rank strings? If you keep them in a lookup table in the database, then it is certainly feasible. Your question is really very generic... are you using an enumerated type? a table? an array? Can you show some code? – Frazz Aug 02 '17 at 07:06
  • The field is an enumerated type of a TMS Aurelius ORM model (so, a integer field of a TAureliusDataset). I populated the combobox values from code in OnCreate event. – orsomannaro Aug 02 '17 at 07:44
  • If you want to do this with live bindings you need to have the values in an enumerable container... like a dataset or some sort of list and hook that up to the combo. If you don't want to use a real dataset, you can opt for an in memory dataset of your choice. – Frazz Aug 02 '17 at 08:11
  • Now i have a UserRak Dataset (Id:integer, Rank:string). Can you help me to setup the bingin? I have try everything without success... – orsomannaro Aug 03 '17 at 14:52
  • OK... From Aurelius manual: Please note that the entity field just represents an object reference. It's useful for lookup fields and to programatically change the object reference in the property, but it's not useful (and should not be used) for visual binding, like a TDBGrid or to be edited in a TDBEdit, since its content is just a pointer to the object. To visual bind properties of associated objects, use sub-property fields. – orsomannaro Aug 07 '17 at 07:55
  • Also: Being a regular lookup field, this approach also works with componentes like TDBLookupComboBox and TDBGrid. It would display a combo with a list of customer names, and will allow you to change the customer of TInvoice object by choosing the item in combo (the field "Customer" in Invoices dataset will be updated with the value of field "Self" in Customers dataset). – orsomannaro Aug 07 '17 at 13:38
  • All seem to work except for the fact that the combobox doesn't show the current value of the field when I open the form (but I can change and save it). – orsomannaro Aug 07 '17 at 13:38

0 Answers0