TProperty Class
TProperty represents a property in an object instance.
Remarks
A TProperty object encapsulates an existing property of an object. It provides methods to read and write property values in different formats, and also provides information about the property, like its default value, its type information, among others. The property might be a real property of the object, or can be a custom or emulated property.
Syntax
Unit: PropertyList
TProperty = class(TObject);
Constructors
| Name | Description |
|---|---|
| Create | Creates a new instance of a TProperty object passing the basic needed parameters. |
Methods
| Name | Description |
|---|---|
| Assign | Copy the content from another property into this one. |
| CreatePropertyList | Creates the internal instance of the property list. Override this method if you want your descendant to use instantiate a different TPropertyList class for the internal property list object. |
| DisplayValue | Retrieves the propery value in a friendly format. For example, if the property is a menu type property, this functions returns '(Menu)'. |
| GetStringValue | Returns the property value in string format. |
| IsCompatible | Checks if the property is compatible with another one. |
| IsCompatibleObject | Returns true if the specified object can be used as a property value. Used for properties of type tkClass. |
| IsCompatibleType | Returns true if the specified type info is compatible with the property. Used for properties of type tkClass. |
| IsType | Check if the property type is same or descending of a specified type. Used for properties of type tkClass. |
| SetEmulatedOff | Restores the property from emulated state by re-acquiring its RTTI information from the instance class. |
| SetEmulatedOn | Forces the property into emulated state by clearing its internal RTTI prop info. |
| SetStringValue | Sets the property value using a string value. |
| ValuesList | Fill a list of valid string values for the property. |
Properties
| Name | Description |
|---|---|
| AsBoolean | Use this property to read or write the property as boolean. |
| AsChar | Use this property to read or write the property as char. |
| AsDate | Use this property to read or write the property as date. |
| AsDateTime | Use this property to read or write the property as date/time. |
| AsFloat | Use this property to read or write the property value as a float format. |
| AsInteger | Use this property to read or write the property as integer. |
| AsInterface | Use this property to read or write the property as interface. |
| AsMethod | Use this property to read or write the property as method/event. |
| AsObject | Use this property to read or write the property as object. |
| AsString | Use this property to read or write the property as string. |
| AsTime | Use this property to read or write the property as time. |
| AsVariant | Use this property to read or write the property as variant. |
| AsWChar | Use this property to read or write the property as wide char. |
| BaseType | If this property is of type tkEnumareted, the BaseType returns the PTypeInfo of the base type of enumerated type. |
| CompType | For set properties, returns the TypeData.CompType value. |
| Custom | Indicates if the property is a custom property. |
| Default | Retrieves the default value of the property. |
| Emulated | Indicates if the property is emulated. |
| EnumCount | For enumerated properties, returns the number of enumerated items. |
| FloatType | For float properties, returns the TFloatType value of the property. |
| FullName | Provides the full qualified name of the property. If the property is a subproperty, FullName retrieves the name of all properties until the current property. For example, Font.Name or Font.Style.fsBold. Use Name property to retrieve only the name of the property. |
| GetProc | Returns a pointer to the GetProc procedure of the property (PropInfo^.GetProc). |
| GUID | For interface properties, retrieves the GUID of the property's interface type. |
| Index | Returns PPropInfo^.Index for the property |
| Instance | The object instance which owns the current property. |
| IntfFlags | For interface properties, retrieves the TIntfFlags of the property. |
| IntfParent | For interface properties, retrieves the PTypeInfo for the parent interface of the property type. |
| IntfUnit | For interface properties, retrieves the IntfUnit of the property's interface type. |
| IsStored | Returns true if the property is stored, false otherwise. |
| Level | Indicates the property level in the property/subproperty tree. |
| MaxInt64Value | Retrieves the maximum valid ordinal value of the property, in Int64 type. |
| MaxLength | For short string properties, return the max length of the string. |
| MaxValue | Retrieves the maximum valid ordinal value of the property. |
| MethodDeclaration | For method (event) properties, retrieves the full method/event declaration. For example. 'procedure(Sender: TObject) of object;' |
| MethodKind | For method (event) properties, retrieves the TMethodKind value associated with the property. |
| MinInt64Value | Retrieves the minimum valid ordinal value of the property, in Int64 type. |
| MinValue | Retrieves the minimum valid ordinal value of the property. |
| Name | Provides the name of the property. |
| NameIndex | Returns PPropInfo^.NameIndex for the property. |
| Names[Index] | For enumerated properties, returns the name of the indexed enumerated item. |
| OrdType | Retrieves the TOrdType value for this property. If the property is not an ordinal type, then returned value is TOrdType(0) |
| Owner | Contains a reference to the TPropertyList object that holds the current property. |
| OwnerProperty | Contains a reference to the owner property of this property, if it exists (if current property is a subproperty). |
| ParamCount | For method (event) properties, retrieves the number of params of the method/event type. |
| Parameters[Index] | For method (event) properties, retrieves the parameter declaration of the specified method/event type. This property might return, for example, 'Sender: TObject', 'var Rect: Rect', etc. |
| ParamFlags[Index] | For method (event) properties, retrieves indexed access for the TParamFlags of a param of the method/event type. |
| ParamNames[Index] | For method (event) properties, retrieves the name of the specified parameter of method/event type. |
| ParamTypes[Index] | For method (event) properties, retrieves the type name of the specified parameter of method/event type. |
| ParentInfo | For class properties, retrieves the PTypeInfo for the parent class of the property type. |
| PropClassType | For class properties, retrieves the TClass reference of the property type. |
| Properties | Holds a list of subproperties of this property. |
| PropType | Holds the PTypeInfo information about the property. |
| ResultType | For method (event) properties, retrieves the type name of the method result. If the method type is not a function, ResultType is an empty string. |
| Root | Contains a reference to the root object that owns the object instance. |
| SetProc | Returns a pointer to the SetProc procedure of the property (PropInfo^.SetProc). |
| TypeData | Holds the PTypeData information about the property. |
| TypeKind | Retrieves the TTypeKind for this property. |
| TypeName | Retrieves the name of the property type. For example, 'string', 'boolean' or 'TDatasource'. |
| UnitName | For class properties, retrieves the name of the unit in which the class was declared. |
| Values[Index] | For enumerated properties, returns the ordinal value of the indexed enumerated item. |