delphi property
2015-11-05 13:02
471 查看
unit Test;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, HGEWinCtrl, StdCtrls;
type
TForm1 = class(TForm)
lbl1: TLabel;
btn1: TButton;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TMyClass = Class
private
B1 : string;
function GetField1: string;
procedure SetField1(AField: string);
public
property A1: string read GetField1 write SetField1;
end;
var
Form1: TForm1;
MyClass : TMyClass;
implementation
{$R *.dfm}
function TMyClass.GetField1: string;
begin
result := B1;
end;
procedure TMyClass.SetField1(AField: string);
begin
B1 := AField;
end;
procedure TForm1.btn1Click(Sender: TObject);
begin
MyClass := TMyClass.Create;
MyClass.A1 := '1111111111'; //赋值会调用SetField1代码段
lbl1.Caption := MyClass.A1;
end;
end.
<script src="https://code.csdn.net/snippets/F1u4Z40656T9395613M8.js"></script>
unit Test;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, HGEWinCtrl, StdCtrls;
type
TForm1 = class(TForm)
lbl1: TLabel;
btn1: TButton;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TMyClass = Class
private
B1 : string;
function GetField1: string;
procedure SetField1(AField: string);
public
property A1: string read GetField1 write SetField1;
end;
var
Form1: TForm1;
MyClass : TMyClass;
implementation
{$R *.dfm}
function TMyClass.GetField1: string;
begin
result := B1;
end;
procedure TMyClass.SetField1(AField: string);
begin
B1 := AField;
end;
procedure TForm1.btn1Click(Sender: TObject);
begin
MyClass := TMyClass.Create;
MyClass.A1 := '1111111111'; //赋值会调用SetField1代码段
lbl1.Caption := MyClass.A1;
end;
end.
<script src="https://code.csdn.net/snippets/F1u4Z40656T9395613M8.js"></script>
相关文章推荐
- delphi 原生 ADODB.recordset
- delphi richedit TopIndex
- SetLength设置动态数组长度的有关问题
- move函数的用法
- 解决Delphi开发DLL中窗体按钮显示状态不刷新问题.
- 最近win7更新后出现第二次打开IDE(delphi2007)的时候提示无法打开"EditorLineEnds.ttr"这个文件
- Delphi WebBrowser与网页交互
- delphi 在桌面屏幕上模拟鼠标单击
- 在delphi中用indy实现FTP上传 下载的例子
- 【《zw版·Halcon与delphi系列原创教程》 zw_halcon人脸识别
- delphi下,不错的多语言翻译组件
- delphi 金额大小写转换函数
- delphi TString使用(取有规律的字符串中某一项内容)
- delphi 中如何查看网页POSTDATA
- delphi 取json中数组的值(ISuperArray)
- Delphi Cookie
- delphi 数组的使用
- delphi一些语法
- delphi取括号内或括号外的内容
- delphi梦魇病毒--解决方法 备着自己用