在学习 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;

Delphi XE2 之 FireMonkey 入门(24) - 数据绑定: TBindingsList: TBindExpression.Direction的更多相关文章

  1. Delphi XE2 之 FireMonkey 入门(30) - 数据绑定: TBindingsList: TBindExpression 的 OnAssigningValue 事件

    Delphi XE2 之 FireMonkey 入门(30) - 数据绑定: TBindingsList: TBindExpression 的 OnAssigningValue 事件 表达式中的函数有 ...

  2. Delphi XE2 之 FireMonkey 入门(23) - 数据绑定: TBindingsList: TBindExpression

    准备用 TBindingsList 重做上一个例子. 可以先把 TBindingsList 理解为是一组绑定表达式(TBindExpression)的集合;官方应该是提倡在设计时完成 TBindExp ...

  3. Delphi XE2 之 FireMonkey 入门(32) - 数据绑定: TBindingsList: TBindList、TBindPosition [未完成...]

    Delphi XE2 之 FireMonkey 入门(32) - 数据绑定: TBindingsList: TBindList.TBindPosition [未完成...] //待补...

  4. Delphi XE2 之 FireMonkey 入门(29) - 数据绑定: TBindingsList: 表达式的 Evaluate() 方法

    Delphi XE2 之 FireMonkey 入门(29) - 数据绑定: TBindingsList: 表达式的 Evaluate() 方法 TBindingsList 中可能不止一个表达式, 通 ...

  5. Delphi XE2 之 FireMonkey 入门(28) - 数据绑定: TBindingsList: 表达式函数测试: SelectedText()、CheckedState()

    Delphi XE2 之 FireMonkey 入门(28) - 数据绑定: TBindingsList: 表达式函数测试: SelectedText().CheckedState() 示例构想: 用 ...

  6. Delphi XE2 之 FireMonkey 入门(27) - 数据绑定: TBindingsList: TBindScope

    Delphi XE2 之 FireMonkey 入门(27) - 数据绑定: TBindingsList: TBindScope 如果在编写表达式时, 如果能够随意指认需要的控件就好了(通过 Owne ...

  7. Delphi XE2 之 FireMonkey 入门(26) - 数据绑定: TBindingsList: TBindExprItems

    Delphi XE2 之 FireMonkey 入门(26) - 数据绑定: TBindingsList: TBindExprItems 如果要给一对 "源控件" 和 " ...

  8. Delphi XE2 之 FireMonkey 入门(25) - 数据绑定: TBindingsList: 表达式的灵活性及表达式函数

    Delphi XE2 之 FireMonkey 入门(25) - 数据绑定: TBindingsList: 表达式的灵活性及表达式函数 绑定表达式中可以有简单的运算和字符串连接, 但字符串需放在双引号 ...

  9. Delphi XE2 之 FireMonkey 入门(31) - 数据绑定: 绑定数据库

    Delphi XE2 之 FireMonkey 入门(31) - 数据绑定: 绑定数据库 一.全设计时操作: 先在窗体上放置控件: DataSource1    : TDataSource; Clie ...

随机推荐

  1. window-tree命令

    tree 以图形方式显示在驱动器中的目录结构或磁盘的路径. 有时候需要整理文档目录时,而文件太多,一个个去写相应的文件目录结构也不现实,就用到了window下的tree命令 语法 tree [< ...

  2. java中的数据类型,基本数据类型及其包装类型

    java中的8大基本类型及其包装类型 1,int--->Integer 2,byte--->Byte 3,short--->Short 4,long--->Long 5,cha ...

  3. Ubuntu16.04 php7.1安装redis扩展

    sudo apt install php7.1-redis //修改php配置 vi /etc/php.ini 添加extension=redis.so

  4. 4Linux 终端命令格式

    Linux 终端命令格式 转自 目标 了解终端命令格式 知道如何查阅终端命令帮助信息 01. 终端命令格式 command [-options] [parameter] 说明: command:命令名 ...

  5. Andronov-Hopf bifurcation

    地址:http://www.scholarpedia.org/article/Andronov-Hopf_bifurcation Andronov-Hopf bifurcation is the bi ...

  6. apply_nodes_func

    import torch as th import dgl g=dgl.DGLGraph() g.add_nodes(3) g.ndata["x"]=th.ones(3,4) #n ...

  7. Ansible笔记(2)--配置清单

    一.Ansible Inventory配置及详解 Inventory是ansible管理主机信息的配置文件,默认存放在/etc/ansible/hosts.在使用时通过 -i 或 --inventor ...

  8. nginx的配置和基本参数说明

    16 117 118 119 120 121 122 123 #运行用户 user nobody; #启动进程,通常设置成和cpu的数量相等 worker_processes  1;   #全局错误日 ...

  9. 小程序里的自定义组件:组件的外部样式externalClasses的使用

    启用外部样式: 自定义组件: v-tag 在html 引入 在组件写外部样式的css : .ex-tag { background-color: #fffbdd ; } 在组件使用该外部的样式 这个时 ...

  10. Vscode添加谷歌Debug插件

    1. 2.安装好 Debugger for Chrome之后,找到要进行Debug的文件 3. 4.进入到launch.json文件中进行相应的配置 配置文件内容如下: { "version ...