RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TBCDField.Create Constructor

Create creates an instance of TBCDField.

Pascal
constructor Create(AOwner: TComponent); override;
C++
virtual __fastcall TBCDField(TComponent * AOwner);

Most applications do not explicitly create instances of TBCDField. 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. 

After calling the inherited constructor, Create sets the DataType property to ftBCD and initializes Size to 4. 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 TBCDField. After instantiating a TBCDField, associate it with a specific field by setting its FieldName property to the name of the field. Give the TBCDField 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 TBCDField with a dataset component by setting its DataSet property to the name of the dataset component. Specify the precision of the TBCDField by setting the Precision property. 

The example below creates a TBCDField object for a field named Amount accessed through a TSQLQuery named SQLQuery1.

var
  T: TBCDField;
begin
  SQLQuery1.Close;
  T := TBCDField.Create(SQLQuery1);
  T.FieldName := 'Amount';
  T.Name := SQLQuery1.Name + T.FieldName;
  T.Index := SQLQuery1.FieldCount;
  T.DataSet := SQLQuery1;
  T.Precision := 2;
  SQLQuery1.FieldDefs.UpDate;
  SQLQuery1.Open;
end;

 

SQLQuery1->Close();
TBCDField *T = new TBCDField(SQLQuery1);
T->FieldName = "Amount";
T->Name = SQLQuery1->Name + T->FieldName;
T->Index = SQLQuery1->FieldCount;
T->DataSet = SQLQuery1;
SQLQuery1->FieldDefs->UpDate();
SQLQuery1->Open();

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!