Data.DB.TWordField.Create

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

constructor Create(AOwner: TComponent); override;

C++

__fastcall virtual TWordField(System::Classes::TComponent* AOwner);

Properties

Type Visibility Source Unit Parent
constructor public
Data.DB.pas
Data.DB.hpp
Data.DB TWordField

Description

Creates an instance of TWordField.

Most applications do not explicitly create instances of TWordField. Instead, the field components are created automatically, as persistent field components defined in the Fields editor at design time or as dynamic field components created automatically by the dataset.

Create sets the DataType property to ftWord, MinValue to 0, and MaxValue to 65535. The AOwner parameter specifies the component, typically a dataset, that becomes the new field's Owner. The Owner is responsible for freeing the component.

In the rare cases when you must create a persistent field component at runtime, call Create to create and initialize an instance of TWordField. After instantiating a TWordField, associate it with a specific field by setting its FieldName property to the name of the field. Give the TWordField a unique identifier in the Name property. Establish where the field appears in the collection of fields by providing an ordinal number in the Index property. Associate the TWordField with a dataset component by setting its DataSet property.

The example below creates a TWordField object for a field named Counter accessed through a TSQLDataSet named SQLDataSet1.



var
T: TWordField;
begin
SQLDataSet1.Close;
T := TWordField.Create(SQLDataSet1);
T.FieldName := 'Counter';
T.Name := SQLDataSet1.Name + T.FieldName;
T.Index := SQLDataSet1.FieldCount;
T.DataSet := SQLDataSet1;
SQLDataSet1.FieldDefs.UpDate;
SQLDataSet1.Open;
end;



SQLDataSet1->Close();
TWordField *T = new TWordField(SQLDataSet1);
T->FieldName = "Counter";
T->Name = SQLDataSet1->Name + T->FieldName;
T->Index = SQLDataSet1->FieldCount;
T->DataSet = SQLDataSet1;
SQLDataSet1->FieldDefs->UpDate();
SQLDataSet1->Open();



See Also