unit DemoFrm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, DBCtrls,
DB, ADODB, Grids, DBGrids;
type
TDemoForm =
class(TForm)
DBGrid: TDBGrid;
ADOConnection: TADOConnection;
DataSource: TDataSource;
ADOTable: TADOTable;
DBNavigator: TDBNavigator;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure ADOTableBeforeInsert(DataSet: TDataSet);
procedure ADOTableNewRecord(DataSet: TDataSet);
private
Defaults: TStrings;
procedure SaveDefaults(Dataset: TDataSet);
procedure LoadDefaults(Dataset: TDataSet);
public
end;
var
DemoForm: TDemoForm;
implementation
{$R *.dfm}
const
FN_NAME = '
NACHNAME';
procedure TDemoForm.SaveDefaults(Dataset: TDataSet);
begin
Defaults.Values[FN_NAME] := DataSet.FieldValues[FN_NAME];
end;
procedure TDemoForm.LoadDefaults(Dataset: TDataSet);
begin
DataSet.FieldValues[FN_NAME] := Defaults.Values[FN_NAME];
end;
procedure TDemoForm.FormCreate(Sender: TObject);
begin
Defaults := TStringList.Create;
end;
procedure TDemoForm.FormDestroy(Sender: TObject);
begin
Defaults.Free;
end;
procedure TDemoForm.ADOTableBeforeInsert(DataSet: TDataSet);
begin
SaveDefaults(DataSet);
end;
procedure TDemoForm.ADOTableNewRecord(DataSet: TDataSet);
begin
LoadDefaults(DataSet);
end;
end.