TTMSFNCDataLinkCSV
TTMSFNCCustomDataLinkCSV
provides functionality for working with CSV (Comma Separated Values) data, enabling records to be manipulated, inserted, and deleted.
The TTMSFNCCustomDataLinkCSV
component can be linked to a TTMSFNCDataSet
component, allowing seamless integration of JSON data into a dataset for display, manipulation, and binding within your application.
Loading a file
To load a CSV file into the TTMSFNCCustomDataLinkCSV
class, there are two options available: via the FileName
property or programmatically using the LoadFromFile
and LoadFromStream
methods.
When using the FileName
property, the file is loaded automatically at design time.
In both cases, the HasFieldNames
, AutoSeparator
and Separator
properties are important. The HasFieldNames
property determines whether the first line of the CSV contains field names. If AutoSeparator
is set to True
, the component will attempt to automatically detect the correct field separator. If AutoSeparator
is False
, the value of the Separator
property will be used as the delimiter between fields.
Automatic saving
The TTMSFNCCustomDataLinkCSV
class supports automatic saving of changes through the AutoSaveChanges
property. When this property is set to True
, any modifications made to the data are automatically saved without requiring an explicit call to save methods. This ensures that changes are persisted seamlessly as they occur.
Methods
Method name | Description |
---|---|
LoadFromFile(AFileName: string; AEncoding: TEncoding) | Loads data from a specified file with the given encoding. |
LoadFromStream(AStream: TStream; AEncoding: TEncoding) | Loads CSV data from a stream with a specific encoding. |
SaveToFile(AFileName: string; AEncoding: TEncoding) | Saves data to a specified file using the given encoding. |
SaveToStream(AStream: TStream; AEncoding: TEncoding) | Saves the current data to a stream in CSV format with a specific encoding. |
Properties
Property name | Description |
---|---|
AutoSaveChanges: Boolean | Controls whether changes to the data are automatically saved. |
AutoSeparator: Boolean | If enabled, the class automatically detects the field separator in the CSV file (comma, semicolon, etc.). |
FileEncoding | Defines the encoding to be used for the file operations (loading and saving data). |
FileName: string | The name of the CSV file associated with the data link. It is used when loading and saving data to a file. |
HasFieldNames: Boolean | Indicates whether the CSV file contains field names in the first row. If set to True , the first row is considered to be the header row. |
QuoteEmptyValues: Boolean | Specifies whether empty values in the CSV file should be enclosed in quotes when saving. |
Separator: Boolean | Defines the character used to separate fields in the CSV file. This value will be used when AutoSeparator is disabled. |