使用Livebindings将多个字段值分配给FMX MetropolisUI TListBox Item.Text

时间:2015-07-03 08:42:34

标签: delphi microsoft-metro firemonkey livebindings tlistbox

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

当我以下列方式使用TBindList时:

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 

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

如果我使用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字段要分配{ {1}}它。

我试图猜测来自'FieldByName("name1").Text + " " + FieldByName("name2").Text'的{​​{1}} Item.Text成员的上下文,但我没有设法。我研究过Delphi样本,但是没有Metropolis TListBox,它似乎采用与普通方式不同的方式。有没有人有任何想法如何找到这个问题的解决方案?

1 个答案:

答案 0 :(得分:1)

感谢@ house-of-dexter的帖子他提出TLabel关于TLinkFillControlToField的帖子,鼓励我再次尝试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

中找到fieldname的上下文
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;

    public class Firefox {

         public void returnFirefoxBrowser(){
             WebDriver driver = new FirefoxDriver();
        }
    }