Default Property Values

From RAD Studio
Jump to: navigation, search

Go Up to Defining Properties


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.

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 instance:

  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, to set string properties to null, or to set Boolean properties to False.

For more information on properties and storage specifiers (stored, default, nodefault), refer to the Properties topic.

Topics

See Also