RAD Studio
ContentsIndex
PreviousUpNext
Default Property Values

When you declare a property, you can specify a default value for it. The VCL uses the default value to determine whether to store the property in a form file. If you do not specify a default value for a property, the VCL always stores the property. 

To specify a default value for a property, append the default directive to the property's declaration (or redeclaration), followed by the default value. For example,

property Cool Boolean read GetCool write SetCool default True;

 

__property bool IsTrue = {read=GetIsTrue, write=SetIsTrue, default=true};

Note: 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.

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!