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

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

4

1 回答 1

7

看看BindLinkVCLProject演示项目。还显示了图像的绑定,所以我猜你需要这样做(SelfinSourceExpression代表一个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
于 2012-05-14T08:18:36.753 回答