{"id":1178,"date":"2014-11-07T17:28:15","date_gmt":"2014-11-07T09:28:15","guid":{"rendered":"http:\/\/blog.qdac.cc\/?p=1178"},"modified":"2015-12-03T15:49:14","modified_gmt":"2015-12-03T07:49:14","slug":"delphi-%e7%9a%84-livebinding-%e5%b0%8f%e7%bb%93","status":"publish","type":"post","link":"https:\/\/blog.qdac.cc\/?p=1178","title":{"rendered":"Delphi \u7684 LiveBinding \u5c0f\u7ed3"},"content":{"rendered":"<p>Delphi\u65b0\u63d0\u4f9b\u4e86LiveBinding\u529f\u80fd\uff0c\u5b9e\u73b0\u4e86\u6570\u636e\u4e0e\u663e\u793a\u7684\u5206\u79bb\u3002LiveBinding\u662f\u4e2a\u597d\u4e1c\u897f\uff0c\u4f46\u6211\u4eec\u9700\u8981\u66f4\u8be6\u7ec6\u7684\u4e86\u89e3\u4e00\u4e0b\uff0c\u624d\u80fd\u66f4\u597d\u7684\u4f7f\u7528\u5b83\u3002<\/p>\n<p>1\u3001\u4ec0\u4e48\u6837\u7684\u63a7\u4ef6\u80fd\u591f\u4f7f\u7528LiveBinding\u529f\u80fd\u7ed1\u5b9a\uff1f<\/p>\n<p>\u51e0\u4e4e\u6240\u6709\u7684\u63a7\u4ef6\uff0c\u5b83\u662f\u57fa\u4e8eRTTI\u4fe1\u606f\u7684\uff0c\u6240\u4ee5\uff0c\u53ea\u8981\u6709RTTI\u4fe1\u606f\u7684\u5730\u65b9\uff0c\u7406\u8bba\u4e0a\u90fd\u53ef\u4ee5\u3002\u4f46\u662f\uff0c\u5b9e\u9645\u4e0a\u5b83\u7c7b\u578b\u4e8eTDataLink\uff0c\u662f\u6709\u4e00\u4e2a\u6570\u636e\u63d0\u4f9b\u7aefServer(IObserver)\u548c\u63a5\u6536\u7ec4\u4ef6\u7684\u3002<\/p>\n<p>2\u3001\u7ed1\u5b9a\u662f\u5355\u5411\u7684\u8fd8\u662f\u53cc\u5411\u7684\uff1f<\/p>\n<p>\u6709\u5355\u5411\u7684\uff0c\u5982TLabel\u7684Caption\/Text\uff0c\u53ea\u80fd\u8d4b\u503c\uff0c\u800c\u4e0d\u80fd\u505a\u4e3a\u63d0\u4f9b\u7aef\uff0c\u800c\u53ea\u80fd\u505a\u4e3a\u63a5\u53d7\u7aef\uff0c\u4e5f\u6709\u53ef\u4ee5\u53cc\u5411\u7684\uff0c\u5982Edit\uff0c\u53ef\u4ee5\u8d4b\u503c\u548c\u66f4\u6539\u5185\u5bb9\u3002<\/p>\n<p>3\u3001\u505aLiveBinding\u524d\u90fd\u5e94\u8be5\u505a\u4ec0\u4e48\uff1f<\/p>\n<p>\u63a8\u8350\u5148\u653e\u4e00\u4e2aTActionList\u4e0a\u53bb\uff0c\u6709\u4e9b\u5e38\u89c4\u52a8\u4f5c\u76f4\u63a5\u5173\u8054\u63a7\u4ef6\u7684Action\uff0c\u7136\u540e\u518d\u4e0e\u4e00\u4e9b\u5c5e\u6027\u7ed1\u5b9a\u5c31\u597d\u4e86\u3002<\/p>\n<p>4\u3001\u5982\u4f55\u8fdb\u884c\u7ed1\u5b9a\uff1f<\/p>\n<p>\u5728\u7a97\u4f53\u4e0a\u53f3\u51fb\uff0c\u9009\u62e9Bind Visually\uff0c\u7136\u540e\u62d6\u62d6\u62c9\u62c9\uff0c\u5efa\u7acb\u63a7\u4ef6\u5b57\u6bb5\u4e4b\u95f4\u7684\u5173\u8054\u5c31\u597d\u4e86\u3002\u6ce8\u610f\u4f60\u770b\u5230\u7684\u53ef\u80fd\u5e76\u4e0d\u662f\u63a7\u4ef6\u7684\u5168\u90e8\u80fd\u7ed1\u5b9a\u7684\u5c5e\u6027\uff0c\u70b9\u51fb\u76f8\u5e94\u7684 LiveBinding \u8bbe\u8ba1\u5668\u63a7\u4ef6\u53f3\u4e0b\u89d2\u7684\u201c&#8230;\u201d\u53ef\u4ee5\u9009\u62e9\u66f4\u591a\u7684\u5c5e\u6027\u3002<\/p>\n<p>\u8fd9\u91cc\u6709\u4e24\u4e2a\u7279\u6b8a\u7684\u5730\u65b9\uff1a<\/p>\n<p>\uff081\uff09\u3001\u6709\u4e9b\u63a7\u4ef6\u5728\u8bbe\u8ba1\u5668\u91cc\u4f1a\u53d1\u73b0 * \u548c Synch \u4e24\u4e2a\u5c5e\u6027\uff0c\u5efa\u7acb\u5b83\u4e24\u7684\u5173\u8054\u53ef\u4ee5\u8ba9\u4e24\u8005\u4e4b\u95f4\u5efa\u7acb\u540c\u6b65\u5173\u7cfb\uff0c\u5982\u4e00\u4e2aTListBox\u548c\u4e00\u4e2aTPrototypeBindSource\uff08\u597d\u4e1c\u897f\uff0c\u5b83\u662f\u751f\u6210\u4e00\u4e2a\u968f\u673a\u7684\u6570\u636e\u6e90\uff0c\u53ef\u4ee5\u7528\u6765\u505a\u6f14\u793a\u6216\u6d4b\u8bd5\u7a0b\u5e8f\uff09\uff0c\u5f53\u4efb\u610f\u4e00\u4e2a\u53d1\u751f\u4f4d\u7f6e\u53d8\u52a8\u65f6\uff0c\u53e6\u4e00\u4e2a\u4e5f\u4f1a\u5b9a\u4f4d\u5230\u76f8\u5e94\u7684\u4f4d\u7f6e\u3002<\/p>\n<p>\uff082\uff09\u3001\u6709\u4e9b\u53ef\u4f9b\u7ed1\u5b9a\u7684\u5c5e\u6027\u53ea\u6709\u5728\u7279\u5b9a\u7684\u5c5e\u6027\u6307\u5b9a\u65f6\uff0c\u624d\u5728\u5217\u8868\u4e2d\u80fd\u663e\u793a\u51fa\u6765\uff0c\u5982\u679c\u4f60\u627e\u4e0d\u5230\u67d0\u4e2a\u53ef\u4ee5\u7ed1\u5b9a\u7684\u5c5e\u6027\uff0c\u5c1d\u8bd5\u770b\u770b\u662f\u4e0d\u662f\u6709\u67d0\u4e2a\u5c5e\u6027\u6ca1\u6709\u8bbe\u7f6e\u6210\u6b63\u786e\u7684\u503c\u3002<\/p>\n<p>5\u3001LiveBinding\u6548\u7387\u5982\u4f55\uff1f<\/p>\n<p>\u8fd9\u79cd\u7701\u5de5\u592b\u7684\u4e1c\u897f\u5f53\u7136\u90fd\u662f\u4ee5\u727a\u7272\u6548\u7387\u4e3a\u4ee3\u4ef7\u7684\u3002\u4f46\u65b9\u4fbf\u3001\u6613\u7528\u6709\u65f6\u5019\u53ef\u4ee5\u8ba9\u6211\u4eec\u66f4\u5feb\u7684\u5b8c\u6210\u5de5\u4f5c\uff0c\u4e0d\u662f\u5f88\u597d\u7684\u4e8b\u60c5\u5417\uff1f<\/p>\n<p>6\u3001\u6211\u53ef\u4ee5\u5b9a\u5236LiveBinding\u89c4\u5219\u5417\uff1f<\/p>\n<p>\u5f53\u7136\u53ef\u4ee5\u3002\u5f53\u4f60\u62d6\u62c9\u5efa\u7acb\u4e00\u4e2a\u5173\u8054\u65f6\uff0c\u4f60\u53ef\u80fd\u6ca1\u6ce8\u610f\u5230\uff0c\u5b83\u81ea\u52a8\u4e3a\u4f60\u586b\u52a0\u4e86\u4e00\u4e2aTBindingsList\u7c7b\u578b\u7684\u7ec4\u4ef6\uff0c\u70b9\u5f00\u5b83\uff0c\u4f60\u4f1a\u53d1\u73b0\u66f4\u591a\u7684\u5965\u79d8\u7684\u54df\u3002\u770b\u770b\u91cc\u9762\u7684\u6bcf\u6761\u89c4\u5219\u7684\u4e8b\u4ef6\uff0c\u4f60\u4f1a\u53d1\u73b0\u4e16\u754c\u4ece\u4e9b\u4e0e\u4f17\u4e0d\u540c\u4e86\u3002<\/p>\n<p>7\u3001\u6211\u600e\u4e48\u52a8\u6001\u521b\u5efa\u7ed1\u5b9a\u89c4\u5219\uff1f<\/p>\n<p>\u80fd\u62d6\u62d6\u62c9\u62c9\u7684\u4e8b\uff0c\u80af\u5b9a\u53ef\u4ee5\u52a8\u6001\u521b\u5efa\u7684\u3002\u5b9e\u9645\u4e0a\uff0c\u4f60\u5728 6 \u4e2d\u770b\u5230\u7684\u6bcf\u6761\u7ed1\u5b9a\u89c4\u5219\uff0c\u90fd\u662f\u00a0TBasicBindComponent \u7684\u5b50\u7c7b\u7684\u5b9e\u4f8b\uff0c\u4f60\u9700\u8981\u7684\u5c31\u662f\u521b\u5efa\u8fd9\u4e9b\u5b9e\u4f8b\uff0c\u7136\u540e\u52a8\u6001\u6dfb\u52a0\u5230\u89c4\u5219\u4e2d\u3002\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre class=\"lang:delphi decode:true \">var\r\n  ABinding: TLinkPropertyToField;\r\nbegin\r\n  \/\/1:\u521b\u5efa\u5bf9\u8c61\r\n  ABinding := TLinkPropertyToField.Create(Self);\r\n  \/\/2.\u8bbe\u7f6e\u5173\u8054\u4fe1\u606f\r\n  ABinding.DataSource := PrototypeBindSource1;\r\n  ABinding.Component := Label1;\r\n  ABinding.ComponentProperty := 'Text';\r\n  ABinding.FieldName := 'ColorsName1';\r\n  \/\/3.\u6fc0\u6d3b\u7ed1\u5b9a\r\n  ABinding.Active:=True;\r\nend;<\/pre>\n<p>8\u3001\u4e3a\u4ec0\u4e48\u4f60\u4e0d\u5199\u4f8b\u5b50\uff1f<\/p>\n<p>\u8fd9\u4e2a\u2026\u2026\u2026\u2026\u2026\u2026\uff0c\u4e00\u4e2a\u5b57\uff0c\u61d2\uff01\u770b\u61c2\uff0c\u4e86\u89e3\u5c31\u597d\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Delphi\u65b0\u63d0\u4f9b\u4e86LiveBindin [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[69,8,21],"tags":[168],"class_list":["post-1178","post","type-post","status-publish","format-standard","hentry","category-c-builder","category-delphi","category-misc","tag-livebinding"],"views":8292,"_links":{"self":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/1178","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1178"}],"version-history":[{"count":6,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/1178\/revisions"}],"predecessor-version":[{"id":3159,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/1178\/revisions\/3159"}],"wp:attachment":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1178"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1178"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1178"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}