2012-05-14 33 views
7

Tôi đang sử dụng Delphi XE2 để viết một ứng dụng VCL win32. Delphi XE2 hỗ trợ ràng buộc trực tiếp. Tôi tải mẫu Biolife.xml vào một cá thể TClientDataSet.Làm thế nào để sử dụng ràng buộc trực tiếp để ràng buộc lĩnh vực blob để kiểm soát TImage?

tôi có thể để ràng buộc một điều khiển TEdit đến lĩnh vực chuỗi dữ liệu của: Loài Tên:

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

sau đó tôi cố gắng để ràng buộc lĩnh vực đồ họa để TImage kiểm soát:

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

Rõ ràng, nó không công việc. Có thể làm như vậy không?

Trả lời

7

Hãy xem qua dự án giới thiệu BindLinkVCLProject. Có hiển thị cũng là một ràng buộc cho hình ảnh, do đó, tôi đoán là bạn cần phải làm điều đó theo cách này (Self trong SourceExpression đại diện cho một lĩnh vực 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 
Các vấn đề liên quan