如何使用实时绑定将Blob字段绑定到TImage控件?

7

我正在使用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

我尝试将图形字段绑定到TImage控件:
object BindLinkImage11: TBindLink
  Category = 'Links'
  SourceMemberName = 'Graphic'
  ControlComponent = Image1
  SourceComponent = BindScopeDB1
  ParseExpressions = <>
  FormatExpressions = <
    item
      ControlExpression = 'Picture'
      SourceExpression = 'Value'
    end>
  ClearExpressions = <>
end

看起来它不起作用。这可能是可能的吗?

1个回答

7
请查看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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接