I am coding a FMX Metropolis UI application and trying to assign two field values of type string to the Item.Title member of TListBox by LiveBindings technology (using expression engine).
When I use a TBindList in the following way:
object BindList1: TBindList
Category = 'Lists'
ControlComponent = ListBox1
SourceComponent = BindSourceDB1
FormatExpressions = <
item
ControlExpression = 'Text'
SourceExpression =
'FieldByName("name1").Text + " " + Field' +
'ByName("name2").Text'
end>
FormatControlExpressions = <>
ClearControlExpressions = <>
end
It assigns the 'name1 name2' string to the member Text but I fail to set the ListItemStyle := MetropolisUI as there is no such property in TBindList class
If I use TLinkFillControlToField
object LinkFillControlToField2: TLinkFillControlToField
Category = 'Quick Bindings'
Control = ListBox1
Track = True
FillDataSource = BindSourceDB1
FillDisplayFieldName = 'name1'
AutoFill = True
BufferCount = -1
AutoBufferCount = False
FillExpressions = <>
FillHeaderExpressions = <>
FillBreakGroups = <>
end
it lets me to assign ListItemStyle to MetropolisUI, but there is only one field that I can access with FillDisplayFieldName property and there is no SourceExpression field to assign 'FieldByName("name1").Text + " " + FieldByName("name2").Text' to it.
I tried to guess context of Item.Text member of TListBox from TBindList but I did not manage to. I studied Delphi samples but there is no Metropolis TListBox and it seems to act in a different way than the common one. Does anybody have any ideas how to find the solution for this issue?
Thanks to the post of @house-of-dexter He gave an answer concerning TLabel that encouraged me to try TLinkFillControlToField once again. The main issue is that the context of the fieldname can be found in Self.Owner.
object LinkFillControlToField2: TLinkFillControlToField
Category = 'Quick Bindings'
DataSource = BindSourceDB1
Control = ListBox1
Track = True
FillDataSource = BindSourceDB1
AutoFill = True
BufferCount = -1
AutoBufferCount = False
ListItemStyle = 'MetropolisUI'
FillExpressions = <
item
SourceMemberName = 'name1'
ControlMemberName = 'Title'
CustomFormat = 'Self.Owner.name1.text+" "+Self.Owner.name2.text'
end>
FillHeaderExpressions = <>
FillBreakGroups = <>
end
来源:https://stackoverflow.com/questions/31202376/using-livebindings-to-assign-several-field-values-to-an-fmx-metropolisui-tlistbo