比如property AutoExpand: Boolean read FAutoExpand write SetAutoExpand default False;
其中的read,write和delfault是什么意思?
还有procedure Expand(Node: TTreeNode); dynamic; 中的dynamic是什么意思?
其中的read,write和delfault是什么意思?
还有procedure Expand(Node: TTreeNode); dynamic; 中的dynamic是什么意思?
解决方案 »
- 如何读数?
- 字段为0时,如何才能不打印出来?
- 救命啊!!!!
- 如何通过TCP传输xml
- 在线收集大家最喜欢玩的游戏(公司一个项目要用到,来者有分啊,下班前结算)
- 如何用MS Agent调用Office助手?
- shelltreeview那几个控件,为什么一用就出错?access violation ???
- 要取出Edit1.text中的前12个字符,让后再取出13-24个字符,要怎么做?
- 一个常见问题!相信大家可以解决的
- !!!!!!!!!!ADO OLE DB连结 ACCESS 数据库(老是说被别人独占方式打开了)报错 ODBC连就没问题 怎么办????
- 用INDY开发FTP工具,怎样实现拖动文件到本地文件夹的功能?谢谢
- Webservices的超难问题!!
write设置此属性的值
delfault默认值
dynamic表明该方法为动态的方法
在Delphi当中,往往将一个类的变量定义在private或者protected里面,这样外部是访问不到这些变量的。当有需要将某个或者某些变量暴露出来给外界访问,就在pulic区或者published区定义一个property。property后面跟着的read表示外界引用这个property的时候,从什么地方返回值,write表示外界给这个property赋值的时候,把这个值放到什么地方去,default对于写控件才有用,表示属性栏里面显示的该属性的缺省值。例如:TMyClass = Class
private
FField1: integer;
FField2: string;
FField3: boolean; function GetField3: boolean;
procedure SetField3(AField: boolean);
public
property Field1: integer read FField1 write FField1;
published
property Field2: string read FField2;
property Field3: boolean read GetField3 write SetField3;
end;implementsfunction TMyClass.GetField3: boolean;
begin
//注意这里用FField3而不是Field3.
result := FField3;
end;procedure TMyClass.SetField3(AField: boolean);
begin
//注意这里用FField3而不是用Field3,因为Field3是专门供外部使用的。
FField3 := AField;
end;
//////////////////////////
//现在你可以这样调用了:
var
myClass: TMyClass;
i: integer;
s: string;
b: boolean;
begin
myClass := TMyClass.Create;
try
myClass.Field1 := 1;
i := myClass.Field1; s := myClass.Field2;
myClass.Field2 := '这句出错,因为Field2是只读的,没有Write'; myClass.Field3 := true; //自动调用TMyClass.SetField3(True)
b := myClass.Field3; //自动调用TMyClass.GetField3返回结果给b
finally
myClass.Free;
end;
end;