比如property AutoExpand: Boolean read FAutoExpand write SetAutoExpand default False;
其中的read,write和delfault是什么意思?
还有procedure Expand(Node: TTreeNode); dynamic;   中的dynamic是什么意思?

解决方案 »

  1.   

    其中的read,write和delfault是什么意思?是读、写、默认的意思呀,不可能不知道吧
      

  2.   

    read读取此属性的值
    write设置此属性的值
    delfault默认值
    dynamic表明该方法为动态的方法
      

  3.   

    关于property.
    在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;
      

  4.   

    还有,私有变量名前面加一个F,而对应的属性名是前面没有那个F。这是Delphi里面约定俗成的编码规范。看Delphi带的代码,可以很强烈的发现这个特点。