[Overview][Constants][Types][Classes][Procedures and functions][Index] | Reference for unit 'db' (#fcl)

# TField

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Provide access to the contents of a single field in a record

## Declaration

Source position: db.pas line 261

`type TField = class(TComponent)`
`public`
`constructor Create(); override;` |  | Create a new TField instance
`destructor Destroy; override;` |  | Destroy the TField instance
`procedure Assign(); override;` |  | Copy properties from one TField instance to another
`procedure AssignValue();` |  | Assign value of a variant record to the field.
`procedure Clear; virtual;` |  | Clear the field contents.
`procedure FocusControl;` |  | Set focus to the first control connected to this field.
`function GetData();` |  | Get the data from this field
`class function IsBlob; virtual;` |  | Is the field a BLOB field (untyped data of indeterminate size).
`function IsValidChar(); virtual;` |  | Check whether a character is valid input for the field
`procedure RefreshLookupList;` |  | Refresh the lookup list
`procedure SetData();` |  | Save the field data
`procedure SetFieldType(); virtual;` |  | Set the field data type
`procedure Validate();` |  | Validate the data buffer
`property AsBCD: TBCD; [rw]` |  | Access the field's contents as a BCD (Binary coded Decimal)
`property AsBoolean: Boolean; [rw]` |  | Access the field's contents as a Boolean value.
`property AsBytes: TBytes; [rw]` |  | Retrieve the contents of the field as an array of bytes
`property AsCurrency: Currency; [rw]` |  | Access the field's contents as a Currency value.
`property AsDateTime: TDateTime; [rw]` |  | Access the field's contents as a TDateTime value.
`property AsFloat: Double; [rw]` |  | Access the field's contents as a floating-point (Double) value.
`property AsLongint: LongInt; [rw]` |  | Access the field's contents as a 32-bit signed integer (longint) value.
`property AsLargeInt: LargeInt; [rw]` |  | Access the field's contents as a 64-bit signed integer (longint) value.
`property AsInteger: LongInt; [rw]` |  | Access the field's contents as a 32-bit signed integer (longint) value.
`property AsString: string; [rw]` |  | Access the field's contents as an AnsiString value.
`property AsWideString: WideString; [rw]` |  | Access the field's contents as a WideString value.
`property AsVariant: variant; [rw]` |  | Access the field's contents as a Variant value.
`property AttributeSet: string; [rw]` |  | Not used: dictionary information
`property Calculated: Boolean; [rw]` |  | Is the field a calculated field ?
`property CanModify: Boolean; [r]` |  | Can the field's contents be modified.
`property CurValue: Variant; [r]` |  | Current value of the field
`property DataSet: TDataSet; [rw]` |  | Dataset this field belongs to
`property DataSize: Integer; [r]` |  | Size of the field's data
`property DataType: TFieldType; [r]` |  | The data type of the field.
`property DisplayName: string; [r]` |  | User-readable fieldname
`property DisplayText: string; [r]` |  | Formatted field value
`property EditMask: TEditMask; [rw]` |  | Specify an edit mask for an edit control
`property EditMaskPtr: TEditMask; [r]` |  | Alias for EditMask
`property FieldNo: LongInt; [r]` |  | Number of the field in the record
`property IsIndexField: Boolean; [r]` |  | Is the field an indexed field ?
`property IsNull: Boolean; [r]` |  | Is the field empty
`property Lookup: Boolean; [rw]` |  | Is the field a lookup field
`property NewValue: Variant; [rw]` |  | The new value of the field
`property Offset: Word; [r]` |  | Offset of the field's value in the dataset buffer
`property Size: Integer; [rw]` |  | Logical size of the field
`property Text: string; [rw]` |  | Text representation of the field
`property ValidChars: TFieldChars; [rw]` |  | Characters that are valid input for the field's content
`property Value: variant; [rw]` |  | Value of the field as a variant value
`property OldValue: variant; [r]` |  | Old value of the field
`property LookupList: TLookupList; [r]` |  | List of lookup values
`published`
`property Alignment: TAlignment; [rw]` |  | Alignment for this field
`property CustomConstraint: string; [rw]` |  | Custom constraint for the field's value
`property ConstraintErrorMessage: string; [rw]` |  | Message to display if the CustomConstraint constraint is violated.
`property DefaultExpression: string; [rw]` |  | Default value for the field
`property DisplayLabel: string; [rws]` |  | Name of the field for display purposes
`property DisplayWidth: LongInt; [rw]` |  | Width of the field in characters
`property FieldKind: TFieldKind; [rw]` |  | The kind of field.
`property FieldName: string; [rw]` |  | Name of the field
`property HasConstraints: Boolean; [r]` |  | Does the field have any constraints defined
`property Index: LongInt; [rw]` |  | Index of the field in the list of fields
`property ImportedConstraint: string; [rw]` |  | Constraint for the field value on the level of the underlying database
`property KeyFields: string; [rw]` |  | Key fields to use when looking up a field value.
`property LookupCache: Boolean; [rw]` |  | Should lookup values be cached
`property LookupDataSet: TDataSet; [rw]` |  | Dataset with lookup values
`property LookupKeyFields: string; [rw]` |  | Names of fields on which to perform a locate
`property LookupResultField: string; [rw]` |  | Name of field to use as lookup value
`property Origin: string; [rw]` |  | Original fieldname of the field.
`property ProviderFlags: TProviderFlags; [rw]` |  | Flags for provider or update support
`property ReadOnly: Boolean; [rw]` |  | Is the field read-only
`property Required: Boolean; [rw]` |  | Does the field require a value
`property Visible: Boolean; [rw]` |  | Should the field be shown in grids
`property OnChange: TFieldNotifyEvent; [rw]` |  | Event triggerd when the field's value has changed
`property OnGetText: TFieldGetTextEvent; [rw]` |  | Event to format the field's content
`property OnSetText: TFieldSetTextEvent; [rw]` |  | Event to set the field's content based on a user-formatted string
`property OnValidate: TFieldNotifyEvent; [rw]` |  | Event to validate the value of a field before it is written to the data buffer
`end;`

## Inheritance

`TField` |  | Provide access to the contents of a single field in a record
`TComponent,IUnknown,IInterfaceComponentReference`
`TPersistent,IFPObserved`
`TObject`

## Description

TField is an abstract class that defines access methods for a field in a record, controlled by a TDataset instance. It provides methods and properties to access the contents of the field in the current record. Reading one of the AsXXX properties of TField will access the field contents and return the contents as the desired type. Writing one of the AsXXX properties will write a value to the buffer represented by the TField instance.

TField is an abstract class, meaning that it should never be created directly. TDataset instances always create one of the descendent classes of TField, depending on the type of the underlying data.

## See also

TDataset |  | Base class for records-based data-access
TFieldDef |  | Class to describe one field in a record in a dataset
TFields |  | Collection of #fcl.db.TField instances

Documentation generated on: Feb 26 2014