Skip to content

TDataSource

Component representing the link between a local (GUI) component and a dataset.

Declaration

Source position: db.pas line 2126

type

  TDataSource = class(TComponent)
  public
    constructor Create;
    destructor Destroy;
    procedure Edit;
    function IsLinkedTo : Boolean;
    property State: TDataSetState; {r}
  published
    property AutoEdit: Boolean; {rwd}
    property DataSet: TDataSet; {rw}
    property Enabled: Boolean; {rwd}
    property OnStateChange: TNotifyEvent; {rw}
    property OnDataChange: TDataChangeEvent; {rw}
    property OnUpdateData: TNotifyEvent; {rw}
  end;

Description

TDatasource is a mediating component: it handles communication between any DB-Aware component (often edit controls on a form) and a TDataset instance. Any database aware component should never communicate with a dataset directly. Instead, it should communicate with a TDatasource instance. The TDataset instance will communicate with the TDatasource instance, which will notify every component attached to it. Vice versa, any component that wishes to make changes to the dataset, will notify the TDatasource instance, which will then (if needed) notify the TDataset instance. The datasource can be disabled, in which case all communication between the dataset and the DB-AWare components is suspended until the datasource is again enabled.

Properties

Member Visibility Description
AutoEdit published Should the dataset be put in edit mode automatically.
DataSet published Dataset this datasource is connected to.
Enabled published Enable or disable sending of events.
State read only public State of the dataset.
See all Properties

Methods

Member Visibility Description
Create public Create a new instance of TDatasource.
Destroy public Remove a TDatasource instance from memory.
Edit public Put the dataset in edit mode, if needed.
IsLinkedTo public Check if a dataset is linked to a certain dataset.
See all Methods

Events

Member Visibility Description
OnDataChange published Called whenever data changes in the current record.
OnStateChange published Called whenever the state of the dataset changes.
OnUpdateData published Called whenever the data in the dataset must be updated.
See all Events

See also

Name Description
TDataset Base class for records-based data-access.
TDatalink Data event handling agent for controls.