Jeg citerer lige helpen fra Delphi :
<CITAT>
TField is the common ancestor of all the field components in a dataset.
Unit
db
Description
TField encapsulates the fundamental behavior common to all field components.
It introduces the properties, events, and methods that are used to:
.. Change the value of a field in a dataset.
.. Convert the value of a field from one data type to another.
.. Validate data that the user enters for a field.
.. Define how the data in the field appears as it is displayed or edited.
.. Calculate the value of a field from code written in the OnCalcFields event
of the dataset.
.. Look up the field's value from another dataset.
Do not create instances of TField. TField descendants are created
automatically each time a dataset is activated. These descendants can be
dynamic (the default) or persistent. Dynamic field components reflect the
actual columns of the underlying physical table at the time a dataset is
opened. Persistent field components are created at design time using the
Fields editor, which specifies the fields in the dataset, their properties,
and their ordering.
Creating persistent field components guarantees that each time an
application runs, it uses and displays the same columns, in the same order,
even if the physical structure of the underlying database changes. If a
column on which a persistent field component is based is deleted or changed,
Delphi generates an exception rather than opening the table against a
nonexistent column or mismatched data. If this happens, remove the field
component for the nonexistent field using the Fields editor.
</CITAT>
Med andre ord, frarådes det kraftigt at man anvender TField direkte. Men
bortset fra det. Så kan du jo ikke
skabe et objekt med sig selv som owner, da det jo ikke er skabt endnu ...
(lidt rekursion der)
Du skaber objektet f.eks. sådan her:
Felt := TField.Create(self); // Formen er owner
eller
Felt := TField.Create(nil); // Der er ingen owner
SÅ håber jeg at det hjalp lidt,
Mvh
Thomas Due
"Nikolaj Woel" <woel@worldonline.dk> wrote in message
news:9033cg$rap$1@news.inet.tele.dk...
>
> > Hej der
> >
> > Du mangler lige at 'create' dit felt .
> >
>
> Sådan her virker heller ikke:
>
> var
> Felt : TField;
> begin
> Felt := TField.Create(Felt);
> Felt.SetFieldType(ftBoolean);
> Felt.FieldName := 'Office';
> Config.Fields.Add(Felt);
> end;
>
>
|