delphi with do 的使用
来源:互联网 发布:猪饲料配方软件 编辑:程序博客网 时间:2024/04/25 23:46
with…do语句用来指定一个块中的字段(记录的或者对象的)、属性和方法所属的记录或者对象。Delphi初学者可能已经习惯了如下的代码书写格式:
var
Button: TButton;
begin
Button := TButton.Create(Self);
Button.Parent := Self;
Button.Left := 50;
Button.Top := 50;
……
end;
每行都写一个Button是否让你感觉厌烦。Object Pascal提供它特有的with…do语句,可以帮你消除这个烦恼。上面的代码可以写为:
var
Button: TButton;
begin
Button := TButton.Create(Self);
with Button do {编译器会知道下面的三个属性属于Button}
begin
Parent := Self;
Left := 50;
Top := 50;
……
end;
end;
with…do中可以包含多个记录或者对象,用逗号隔开。with…do也可以嵌套使用。
var
Button: TButton;
begin
Button := TButton.Create(Self);
Button.Parent := Self;
Button.Left := 50;
Button.Top := 50;
……
end;
每行都写一个Button是否让你感觉厌烦。Object Pascal提供它特有的with…do语句,可以帮你消除这个烦恼。上面的代码可以写为:
var
Button: TButton;
begin
Button := TButton.Create(Self);
with Button do {编译器会知道下面的三个属性属于Button}
begin
Parent := Self;
Left := 50;
Top := 50;
……
end;
end;
with…do中可以包含多个记录或者对象,用逗号隔开。with…do也可以嵌套使用。
0 0
- delphi with do 的使用
- delphi:with do用法
- delphi with do和for do语句
- with do的意义
- Delphi while do 语句使用
- Delphi for do 语句使用
- delphi for xx in xx do 语法的使用示例
- 简单使用Delphi中的TO-DO List
- 简单使用Delphi中的TO-DO List
- do while的使用
- do...while的使用
- do语句的使用
- do{} while(0)的使用
- do while结构的使用
- do while{0}的使用
- do{}while(0)的使用
- Java do-while的使用
- BAPI / RFC with Delphi(系列之二)--TSAPLogonControl使用(有对话框的登录sap的delphi源代码)
- poj 3335 Rotating Scoreboard
- poj 1474 Video Surveillance
- 半平面交
- Yii的一些安全防范措施
- 模板引擎的存在
- delphi with do 的使用
- DHCP Snooping功能与实例详解
- 互联网思维(通俗理解)
- luci 添加helloword模块
- 学习C++模板,初体验
- import static和import
- svn在先安装和eclipse启动是否选择空间
- CSS3中Opacity透明度等一些特效
- SVN删除文件及其恢复