Tfield |
Tfielddef |
Tfields |
Tfielddefs |
Tfieldlist, tfielddeflist |
Assign Assignvalue Clear Focuscontrol Getdata Getparentcomponent Hasparent Isblob Isvalidchar Refreshlookuplist Setdata Setfieldtype Setparentcomponent ValidateAsbcd Asboolean Ascurrency Asdatetime Assqltimestamp Assqltimestampoffset Assingle Asfloat Asextended Asinteger Aslargeint Asstring Aswidestring Asansistring Asbytes Asvariant Attributeset Calculated Canmodify Curvalue Dataset Datasize Datatype Displayname Displaytext Editmask Editmaskptr Fieldno Fullname Isindexfield Isnull Lookup Lookuplist Newvalue Offset Oldvalue Parentfield Size Text Validchars Value Alignment Autogeneratevalue Customconstraint Constrainterrormessage Defaultexpression Displaylabel Displaywidth Fieldkind Fieldname Hasconstraints Index Importedconstraint Lookupdataset Lookupkeyfields Lookupresultfield Keyfields Lookupcache Origin Providerflags Readonly Required Visible Onchange Ongettext Onsettext Onvalidate |
Addchild Assign Createfield HaschilddefsFieldclass Fieldno Internalcalcfield Parentdef Required Attributes Childdefs Datatype Precision Size Name Getnamepath Collection ID Index Displayname |
Add Checkfieldname Checkfieldnames Clear Findfield Fieldbyname Fieldbynumber Getenumerator Getfieldnames Indexof Remove Count Dataset Fields |
Addfielddef Find Update Add Getitemnames Indexof Owner Assign Beginupdate Clear Delete Endupdate Finditemid Getenumerator Getnamepath InsertHiddenfields Items Parentdef Dataset Updated Capacity Count Itemclass |
Fieldbyname Find Fields (fielddefs) Update Dataset Add Addobject Clear Delete Exchange Indexof Insert Insertobject Sort Customsort Append Addstrings Assign Beginupdate Endupdate Equals Getenumerator Gettext Indexofname Indexofobject Loadfromfile Loadfromstream Move Savetofile Savetostream SettextDuplicates Sorted Casesensitive Capacity Commatext Count Delimiter Delimitedtext Linebreak Names Objects Quotechar Values Valuefromindex Namevalueseparator Strictdelimiter Strings Text Stringsadapter Onchange Onchanging Ownsobjects |
I found these things mature as early as in Delphi 3, and have not changed so far. My current understanding of them is:
1. fields is a set of fields. They are mainly used for accessing field metadata and field values during runtime.
2. fielddefs is a collection of fielddef. They are mainly used to construct a dataset (table) and access field metadata.
3. fieldlist and fielddeflist are shortcut lists for accessing field and fielddef respectively. They mainly use the fieldbyname, find method, and default array attribute to access data. They are read-only.
4. You can obtain more information through fields, fieldlist, and field, but it must be when the dataset is opened;
You can use fielddefs, fielddeflist, and fielddef to obtain only the defined information, but it can be used even when the dataset is closed.
5. As the name suggests, fielddef is used to define tables, but tables can also be defined through field;
It is convenient to define a table using fielddef and use field to define more complex tables;
Each fielddef corresponds to a field, but a field does not necessarily have a fielddef;
After the program runs, fielddef cannot be changed, while field and fields can be dynamically changed or increased or decreased.
Both are used in combination during design.
The following code creates a table dynamically using three methods:
// Use tfielddef to create a table: Begin with clientdataset1.fielddefs do begin add ('name', ftstring, 12, true); {true indicates a required field} Add ('age ', ftinteger); end; clientdataset1.createdataset; end; // use tfield (its subclass is used here) to create a table: Begin with tstringfield. create (Self) Do begin fieldname: = 'name'; Size: = 12; required: = true; {required field} Dataset: = clientdataset1; end; with tintegerfield. create (Self) Do begin fieldname: = 'age'; Dataset: = clientdataset1; end; clientdataset1.createdataset; end; // hybrid use (this seems to be the case during design ): vaR F: tintegerfield; begin with clientdataset1.fielddefs. addfielddef do begin name: = 'name'; ype: = ftstring; Size: = 12; required: = true; createfield (clientdataset1); end; with clientdataset1.fielddefs. addfielddef do begin name: = 'age'; ype: = ftinteger; {specify the maximum and minimum values} f: = createfield (clientdataset1) as tintegerfield; F. minvalue: = 0; F. maxvalue: = 150; end; clientdataset1.createdataset; end;
Field Type list:
TStringField { ftString ; String }TWideStringField { ftWideString ; WideString }TNumericField { }TIntegerField { ftInteger ; Integer }TLongWordField { ftLongWord ; LongWord }TSmallintField { ftSmallint ; Smallint }TShortintField { ftShortint ; Shortint }TByteField { ftByte ; Byte }TLargeintField { ftLargeint ; Int64 }TWordField { ftWord ; Word }TAutoIncField { ftAutoInc ; Integer }TUnsignedAutoIncField { ftAutoInc ; Cardinal }TFloatField { ftFloat ; Double }TSingleField { ftSingle ; Single }TCurrencyField { ftCurrency ; Currency }TExtendedField { ftExtended ; Extended }TBooleanField { ftBoolean ; WordBool }TDateTimeField { ftDateTime ; DateTime }TSQLTimeStampField { ftTimeStamp ; TSQLTimeStamp }TSQLTimeStampField { ftTimeStampOffset; TSQLTimeStampOffset }TDateField { ftDate ; Integer }TTimeField { ftTime ; Integer }TBinaryField { }TBytesField { ftBytes ; * }TVarBytesField { ftVarBytes ; * }TBCDField { ftBCD ; * }TFMTBCDField { ftFMTBCD ; * }TBlobField { ftBlob ; * }TMemoField { ftMemo ; * }TWideMemoField { ftWideMemo ; * }TGraphicField { ftGraphic ; * }TObjectField { }TADTField { ftADT ; * }TArrayField { ftArray ; * }TDataSetField { ftDataSet ; TDataSet }TReferenceField { ftReference ; * }TVariantField { ftVariant ; OleVariant }TInterfaceField { ftInterface ; IUnknown }TIDispatchField { ftIDispatch ; IDispatch }TGuidField { ftGuid ; TGUID }TAggregateField { ftUnknown ; * }