Delphi XE2 之 FireMonkey 入门(24) - 数据绑定: TBindingsList: TBindExpression.Direction
2024-10-07 10:58:10
在学习 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;
最新文章
- Javascript之匿名函数
- 有关windows系统的EXE和DLL文件说法错误
- enmo_day_09
- IIS-反向代理
- [POJ1159]Palindrome(dp,滚动数组)
- 对App数据库元素进行简单的设计
- [转]easyui常用控件及样式收藏
- 51nod 1118 机器人走方格 解题思路:动态规划 &; 1119 机器人走方格 V2 解题思路:根据杨辉三角转化问题为组合数和求逆元问题
- d3力导向图聚焦
- 当锚点遇到fixed
- 通过URL触发Jenkins构建
- @RequestParam 和@RequestBody 的区别?
- 19、Squid代理服务器
- 给对话框添加动画 Dialog
- iText C# 合并PDF文件流,以及A5变A4时内容默认放在最底下的问题的解决方法;ASP.NET 实现Base64文件流下载PDF
- android -------- 颜色的半透明效果配置
- P<;0.05就够了?还要校正!校正!3个方法献上
- JAVA框架 Spring 和Mybatis整合(传统dao)
- 第三百四十三节,Python分布式爬虫打造搜索引擎Scrapy精讲—scrapy模拟登陆和知乎倒立文字验证码识别
- 通过url获取参数信息
热门文章
- css水平垂直居中问题
- vue中使用better-scroll滚动条插件
- 安装sysbench,报错";Could not resolve &#39;ports.ubuntu.com&#39;";
- windows_vs编译过程
- thinkphp5 select对象怎么转数组?
- Win10遇到蓝屏错误CRITICAL_STRUCTURE_CORRUPTION如何解决
- Linux 正在尝试其他镜像
- 【学习】019 SpringBoot
- 【学习】014 深入理解Http协议
- GUI学习之二十——QAbstractSlider学习总结