[Overview][Constants][Types][Classes][Procedures and functions][Index] | Reference for unit 'db' (#fcl)

# TDataLink

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Data event handling agent for controls

## Declaration

Source position: db.pas line 1648

`type TDataLink = class(TPersistent)`
`protected`
`procedure ActiveChanged; virtual;`
`procedure CheckBrowseMode; virtual;`
`procedure DataEvent(); virtual;`
`procedure DataSetChanged; virtual;`
`procedure DataSetScrolled(); virtual;`
`procedure EditingChanged; virtual;`
`procedure FocusControl(); virtual;`
`function GetActiveRecord; virtual;`
`function GetBOF; virtual;`
`function GetBufferCount; virtual;`
`function GetEOF; virtual;`
`function GetRecordCount; virtual;`
`procedure LayoutChanged; virtual;`
`function MoveBy(); virtual;`
`procedure RecordChanged(); virtual;`
`procedure SetActiveRecord(); virtual;`
`procedure SetBufferCount(); virtual;`
`procedure UpdateData; virtual;`
`property VisualControl: Boolean; [rw]`
`property FirstRecord: Integer; [rw]`
`public`
`constructor Create;` |  | Initialize a new instance of TDataLink
`destructor Destroy; override;` |  | Remove an instance of TDatalink from memory
`function Edit;` |  | Set the dataset in edit mode, if possible
`procedure UpdateRecord;` |  | Called when the data in the dataset must be updated
`function ExecuteAction(); virtual;` |  | Execute action
`function UpdateAction(); virtual;` |  | Update handler for actions
`property Active: Boolean; [r]` |  | Is the link active
`property ActiveRecord: Integer; [rw]` |  | Currently active record
`property BOF: Boolean; [r]` |  | Is the dataset at the first record
`property BufferCount: Integer; [rw]` |  | Set to the number of record buffers this datalink needs.
`property DataSet: TDataSet; [r]` |  | Dataset this datalink is connected to
`property DataSource: TDatasource; [rw]` |  | Datasource this datalink is connected to
`property DataSourceFixed: Boolean; [rw]` |  | Can the datasource be changed
`property Editing: Boolean; [r]` |  | Is the dataset in edit mode
`property Eof: Boolean; [r]` |  |
`property ReadOnly: Boolean; [rw]` |  | Is the link readonly
`property RecordCount: Integer; [r]` |  | Number of records in the buffer of the dataset
`end;`

## Inheritance

`TDataLink` |  | Data event handling agent for controls
`TPersistent`
`TObject`

## Description

TDataLink is used by GUI controls or datasets in a master-detail relationship to handle data events coming from a TDatasource instance. It is a class that exists for component programmers, application coders should never need to use TDataLink or one of it's descendents.

DB-Aware Component coders must use a TDatalink instance to handle all communication with a TDataset instance, rather than communicating directly with the dataset. TDataLink contains methods which are called by the various events triggered by the dataset. Inversely, it has some methods to trigger actions in the dataset.

TDatalink is an abstract class; it is never used directly. Instead, a descendent class is used which overrides the various methods that are called in response to the events triggered by the dataset. Examples are .

## See also

TDataset |  | Base class for records-based data-access
TDatasource |  | Component representing the link between a local (GUI) component and a dataset
TDetailDatalink |  | Represents the link between a detail data source and a master datasource.
TMasterDataLink |  | Datalink for Master-Detail relationships between datasets.

The latest version of this document can be found at lazarus-ccr.sourceforge.net .