使用Livebindings为FMX MetropolisUI TListBox Item.Text分配多个字段值 [英] Using Livebindings to Assign Several Field Values to an FMX MetropolisUI TListBox Item.Text

查看:144
本文介绍了使用Livebindings为FMX MetropolisUI TListBox Item.Text分配多个字段值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编码FMX Metropolis UI应用程序,并尝试通过LiveBindings技术(使用表达式引擎)将两个字符串类型的字段值分配给TListBox的Item.Title成员.

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

当我通过以下方式使用TBindList时:

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 

它为成员Text分配了'name1 name2'字符串,但由于TBindList类中没有这样的属性,我无法设置ListItemStyle := MetropolisUI

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

如果我使用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

它允许我将ListItemStyle分配给MetropolisUI,但是只有一个字段可以使用FillDisplayFieldName属性访问,没有SourceExpression字段可以将'FieldByName("name1").Text + " " + FieldByName("name2").Text'分配给它.

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.

我试图从TBindList猜测TListBoxItem.Text成员的上下文,但是我没有设法.我研究了Delphi样本,但没有Metropolis TListBox,它的行为方式与普通样本不同.是否有人有想法找到解决此问题的方法?

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?

推荐答案

感谢@ house-of-dexter的帖子,他给了TLabel的> answer 鼓励了我再次尝试.主要问题是可以在Self.Owner中找到字段名的上下文.

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

这篇关于使用Livebindings为FMX MetropolisUI TListBox Item.Text分配多个字段值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆