在学习 BindingSource 属性时, 可以让两个控件互为绑定源; TBindExpression 对应的功能是 Direction 属性.

先在窗体上添加 Edit1、Edit2、BindingsList1; 然后激活 Edit1、Edit2 和窗体的默认事件.


procedure TForm1.FormCreate(Sender: TObject);
begin
  with TBindExpression.Create(BindingsList1) do
  begin
    ControlComponent := Edit2;
    ControlExpression := 'Text';
    SourceComponent := Edit1;
    SourceExpression := 'Text';
//    Direction := TExpressionDirection.dirSourceToControl; //默认
//    Direction := TExpressionDirection.dirControlToSource; //反向
    Direction := TExpressionDirection.dirBidirectional;    //双向
    Active := True;
  end;
end; procedure TForm1.Edit1Change(Sender: TObject);
begin
  BindingsList1.Notify(Sender, '');
end; procedure TForm1.Edit2Change(Sender: TObject);
begin
  BindingsList1.Notify(Sender, '');
end;

如果没有 Direction 属性, 代码或许会是:


procedure TForm1.FormCreate(Sender: TObject);
begin
  with TBindExpression.Create(BindingsList1) do
  begin
    ControlComponent := Edit2;
    ControlExpression := 'Text';
    SourceComponent := Edit1;
    SourceExpression := 'Text';
    Active := True;
  end;   with TBindExpression.Create(BindingsList1) do
  begin
    ControlComponent := Edit1;
    ControlExpression := 'Text';
    SourceComponent := Edit2;
    SourceExpression := 'Text';
    Active := True;
  end;
end; procedure TForm1.Edit1Change(Sender: TObject);
begin
  BindingsList1.Notify(Sender, '');
end; procedure TForm1.Edit2Change(Sender: TObject);
begin
  BindingsList1.Notify(Sender, '');
end;

最新文章

  1. Javascript之匿名函数
  2. 有关windows系统的EXE和DLL文件说法错误
  3. enmo_day_09
  4. IIS-反向代理
  5. [POJ1159]Palindrome(dp,滚动数组)
  6. 对App数据库元素进行简单的设计
  7. [转]easyui常用控件及样式收藏
  8. 51nod 1118 机器人走方格 解题思路:动态规划 & 1119 机器人走方格 V2 解题思路:根据杨辉三角转化问题为组合数和求逆元问题
  9. d3力导向图聚焦
  10. 当锚点遇到fixed
  11. 通过URL触发Jenkins构建
  12. @RequestParam 和@RequestBody 的区别?
  13. 19、Squid代理服务器
  14. 给对话框添加动画 Dialog
  15. iText C# 合并PDF文件流,以及A5变A4时内容默认放在最底下的问题的解决方法;ASP.NET 实现Base64文件流下载PDF
  16. android -------- 颜色的半透明效果配置
  17. P<0.05就够了?还要校正!校正!3个方法献上
  18. JAVA框架 Spring 和Mybatis整合(传统dao)
  19. 第三百四十三节,Python分布式爬虫打造搜索引擎Scrapy精讲—scrapy模拟登陆和知乎倒立文字验证码识别
  20. 通过url获取参数信息

热门文章

  1. css水平垂直居中问题
  2. vue中使用better-scroll滚动条插件
  3. 安装sysbench,报错"Could not resolve 'ports.ubuntu.com'"
  4. windows_vs编译过程
  5. thinkphp5 select对象怎么转数组?
  6. Win10遇到蓝屏错误CRITICAL_STRUCTURE_CORRUPTION如何解决
  7. Linux 正在尝试其他镜像
  8. 【学习】019 SpringBoot
  9. 【学习】014 深入理解Http协议
  10. GUI学习之二十——QAbstractSlider学习总结