Skip to content

TField

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

Declaration

Source position: db.pas line 288

type

  TField = class(TComponent)
  public
    constructor Create;
    destructor Destroy;
    procedure Assign;
    procedure AssignValue;
    procedure Clear;
    procedure FocusControl;
    function GetData(Buffer: Pointer) : Boolean; overload;
    function GetData(Buffer: Pointer; NativeFormat: Boolean) : Boolean; overload;
    class function IsBlob : Boolean;
    function IsValidChar : Boolean;
    procedure RefreshLookupList;
    procedure SetData(Buffer: Pointer); overload;
    procedure SetData(Buffer: Pointer; NativeFormat: Boolean); overload;
    procedure SetFieldType;
    procedure Validate;
    property AsBCD: TBCD; {rw}
    property AsBoolean: Boolean; {rw}
    property AsBytes: TBytes; {rw}
    property AsCurrency: Currency; {rw}
    property AsDateTime: TDateTime; {rw}
    property AsExtended: Extended; {rw}
    property AsFloat: Double; {rw}
    property AsLongint: LongInt; {rw}
    property AsLongWord: LongWord; {rw}
    property AsLargeInt: LargeInt; {rw}
    property AsInteger: LongInt; {rw}
    property AsSingle: Single; {rw}
    property AsString: string; {rw}
    property AsAnsiString: AnsiString; {rw}
    property AsUnicodeString: UnicodeString; {rw}
    property AsUTF8String: UTF8String; {rw}
    property AsWideString: WideString; {rw}
    property AsVariant: variant; {rw}
    property AttributeSet: string; {rw}
    property Calculated: Boolean; {rw}
    property CanModify: Boolean; {r}
    property CurValue: Variant; {r}
    property DataSet: TDataSet; {rw}
    property DataSize: Integer; {r}
    property DataType: TFieldType; {r}
    property DisplayName: string; {r}
    property DisplayText: string; {r}
    property EditMask: TEditMask; {rw}
    property EditMaskPtr: TEditMask; {r}
    property FieldNo: LongInt; {r}
    property IsIndexField: Boolean; {r}
    property IsNull: Boolean; {r}
    property NewValue: Variant; {rw}
    property Offset: Word; {r}
    property Size: Integer; {rw}
    property Text: string; {rw}
    property ValidChars: TFieldChars; {rw}
    property Value: variant; {rw}
    property OldValue: variant; {r}
    property LookupList: TLookupList; {r}
    property FieldDef: TFieldDef; {r}
  published
    property Alignment: TAlignment; {rwd}
    property CustomConstraint: string; {rw}
    property ConstraintErrorMessage: string; {rw}
    property DefaultExpression: string; {rw}
    property DisplayLabel: string; {rws}
    property DisplayWidth: LongInt; {rws}
    property FieldKind: TFieldKind; {rw}
    property FieldName: string; {rw}
    property HasConstraints: Boolean; {r}
    property Index: LongInt; {rw}
    property ImportedConstraint: string; {rw}
    property KeyFields: string; {rw}
    property LookupCache: Boolean; {rwd}
    property LookupDataSet: TDataSet; {rw}
    property LookupKeyFields: string; {rw}
    property LookupResultField: string; {rw}
    property Lookup: Boolean; {rws}
    property Origin: string; {rw}
    property ParentField: TObjectField; {rw}
    property ProviderFlags: TProviderFlags; {rw}
    property ReadOnly: Boolean; {rwd}
    property Required: Boolean; {rwd}
    property Visible: Boolean; {rwd}
    property OnChange: TFieldNotifyEvent; {rw}
    property OnGetText: TFieldGetTextEvent; {rw}
    property OnSetText: TFieldSetTextEvent; {rw}
    property OnValidate: TFieldNotifyEvent; {rw}
  end;

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.

Properties

Member Visibility Description
Alignment published Alignment for this field.
AsAnsiString public Return field contents as an ANSI string.
AsBCD public Access the field's contents as a BCD (Binary coded Decimal).
AsBoolean public Access the field's contents as a Boolean value.
AsBytes public Retrieve the contents of the field as an array of bytes.
AsCurrency public Access the field's contents as a Currency value.
AsDateTime public Access the field's contents as a TDateTime value.
AsExtended public
AsFloat public Access the field's contents as a floating-point (Double) value.
AsInteger public Access the field's contents as a 32-bit signed integer (longint) value.
AsLargeInt public Access the field's contents as a 64-bit signed integer (longint) value.
AsLongint public Access the field's contents as a 32-bit signed integer (longint) value.
AsLongWord public Access field contents as 32-bit unsigned integer (longword/cardinal).
AsSingle public
AsString public Access the field's contents as an AnsiString value.
AsUnicodeString public Field contents as a UnicodeString.
AsUTF8String public Field contents as a UTF8 String.
AsVariant public Access the field's contents as a Variant value.
AsWideString public Access the field's contents as a WideString value.
AttributeSet public Not used: dictionary information.
Calculated public Is the field a calculated field ?
CanModify read only public Can the field's contents be modified.
ConstraintErrorMessage published Message to display if the CustomConstraint constraint is violated.
CurValue read only public Current value of the field.
CustomConstraint published Custom constraint for the field's value.
DataSet public Dataset this field belongs to.
DataSize read only public Size of the field's data.
DataType read only public The data type of the field.
DefaultExpression published Default value for the field.
DisplayLabel published Name of the field for display purposes.
DisplayName read only public User-readable fieldname.
DisplayText read only public Formatted field value.
DisplayWidth published Width of the field in characters.
EditMask public Specify an edit mask for an edit control.
EditMaskPtr read only public Alias for EditMask.
FieldDef read only public Fielddef associated with this field.
FieldKind published The kind of field.
FieldName published Name of the field.
FieldNo read only public Number of the field in the record.
HasConstraints read only published Does the field have any constraints defined.
ImportedConstraint published Constraint for the field value on the level of the underlying database.
Index published Index of the field in the list of fields.
IsIndexField read only public Is the field an indexed field ?
IsNull read only public Is the field empty.
KeyFields published Key fields to use when looking up a field value.
Lookup published Is the field a lookup field.
LookupCache published Should lookup values be cached.
LookupDataSet published Dataset with lookup values.
LookupKeyFields published Names of fields on which to perform a locate.
LookupList read only public List of lookup values.
LookupResultField published Name of field to use as lookup value.
NewValue public The new value of the field.
Offset read only public Offset of the field's value in the dataset buffer.
OldValue read only public Old value of the field.
Origin published Original fieldname of the field.
ParentField published
ProviderFlags published Flags for provider or update support.
ReadOnly published Is the field read-only.
Required published Does the field require a value.
Size public Logical size of the field.
Text public Text representation of the field.
ValidChars public Characters that are valid input for the field's content.
Value public Value of the field as a variant value.
Visible published Should the field be shown in grids.
See all Properties

Methods

Member Visibility Description
Assign public Copy properties from one TField instance to another.
AssignValue public Assign value of a variant record to the field.
Clear public Clear the field contents.
Create public Create a new TField instance.
Destroy public Destroy the TField instance.
FocusControl public Set focus to the first control connected to this field.
GetData public Get the data from this field.
IsBlob public Is the field a BLOB field (untyped data of indeterminate size).
IsValidChar public Check whether a character is valid input for the field.
RefreshLookupList public Refresh the lookup list.
SetData public Save the field data.
SetFieldType public Set the field data type.
Validate public Validate the data buffer.
See all Methods

Events

Member Visibility Description
OnChange published Event triggered when the field's value has changed.
OnGetText published Event to format the field's content.
OnSetText published Event to set the field's content based on a user-formatted string.
OnValidate published Event to validate the value of a field before it is written to the data buffer.
See all Events

See also

Name Description
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.