【问题标题】:How to use live binding to bind blob field to TImage control?如何使用实时绑定将 blob 字段绑定到 TImage 控件?
【发布时间】:2012-05-14 07:09:47
【问题描述】:

我正在使用 Delphi XE2 编写一个 VCL win32 应用程序。 Delphi XE2 支持实时绑定。我将示例 Biolife.xml 加载到 TClientDataSet 实例中。

我能够将 TEdit 控件绑定到数据集的字符串字段:物种名称:

object BindLinkEdit11: TBindLink
  Category = 'Links'
  SourceMemberName = 'Species Name'
  ControlComponent = Edit1
  SourceComponent = BindScopeDB1
  ParseExpressions = <>
  FormatExpressions = <
    item
      ControlExpression = 'Text'
      SourceExpression = 'DisplayText'
    end>
  ClearExpressions = <>
end

然后我尝试将 Graphic 字段绑定到 TImage 控件:

object BindLinkImage11: TBindLink
  Category = 'Links'
  SourceMemberName = 'Graphic'
  ControlComponent = Image1
  SourceComponent = BindScopeDB1
  ParseExpressions = <>
  FormatExpressions = <
    item
      ControlExpression = 'Picture'
      SourceExpression = 'Value'
    end>
  ClearExpressions = <>
end

显然,它不起作用。有可能这样做吗?

【问题讨论】:

    标签: delphi delphi-xe2 livebindings


    【解决方案1】:

    查看BindLinkVCLProject 演示项目。还显示了图像的绑定,所以我猜你需要这样做(SourceExpression 中的Self 代表一个 blob 字段):

    object BindLinkImageHandler: TBindLink
      Category = 'Links'
      SourceMemberName = 'Graphic'
      ControlComponent = Image1
      SourceComponent = BindScopeDB1
      ParseExpressions = <
        item
          ControlExpression = 'Picture'
          SourceExpression = 'Self'
        end>
      FormatExpressions = <
        item
          ControlExpression = 'Picture'
          SourceExpression = 'Self'
        end>
      ClearExpressions = <
        item
          ControlExpression = 'Picture'
          SourceExpression = 'nil'
        end>
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-24
      • 2015-09-27
      • 1970-01-01
      • 1970-01-01
      • 2012-10-30
      • 2017-02-16
      相关资源
      最近更新 更多