Data.DB.TWideStringField.Create

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

constructor Create(AOwner: TComponent); override;

C++

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

Properties

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

Description

Creates an instance of a TWideStringField object.

Most applications do not explicitly create instances of TWideStringField. 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 ftWideString, Size to 20, and Transliterate to true. 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 TWideStringField. After instantiating a TWideStringField, associate it with a specific field by setting its FieldName property to the name of the field. Give the TWideStringField 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 TWideStringField with a dataset component by setting its DataSet property.

The example below creates a TWideStringField object for a field named BookList accessed through a TQuery named Query1.



var
T: TWideStringField;
begin
Query1.Close;
T := TWideStringField.Create(Query1);
T.FieldName := 'BookList';
T.Name := Query1.Name + T.FieldName;
T.Index := Query1.FieldCount;
T.DataSet := Query1;
Query1.FieldDefs.UpDate;
Query1.Open;
end;



TWideStringField *T;
Query1->Close();
T = new TWideStringField(Query1);
T->FieldName = "LastName";
T->Name = Query1->Name + T->FieldName;
T->Index = Query1->FieldCount;
T->DataSet = Query1;
Query1->FieldDefs->UpDate();
Query1->Open();



See Also