作自定义组件时,发现default不好用?如:property Text: string read FText write SetText default '0';

解决方案 »

  1.   

    默认值只能是integer,Boolean等有序类型,String不行
      

  2.   

    Declaring a default value does not set the property to that value. The component's constructor method should initialize property values when appropriate. However, since objects always initialize their fields to 0, it is not strictly necessary for the constructor to set integer properties to 0, string properties to null, or Boolean properties to False.
      

  3.   

    default 只有integer,Boolean很少的几种有用
    构造函数中自己写(这也是个好习惯)