RAD Studio VCL Reference
|
Occurs after an application completes a request to cancel modifications to the active record.
property AfterCancel: TDataSetNotifyEvent;
__property TDataSetNotifyEvent AfterCancel;
Write an AfterCancel event handler to take specific action after an application cancels changes to the active record. AfterCancel is called by the Cancel method after it updates the current position, releases the lock on the active record if necessary, and sets the dataset state to dsBrowse. If an application requires additional processing before returning control to a user after a Cancel event, code it in the AfterCancel event.
Delphi Examples:
{ This example updates the form’s status bar with a message when an AfterCancel event occurs. Set the StatusBar SimplePanel property to True. } procedure TForm1.Table1AfterCancel(DataSet: TDataSet); begin StatusBar1.SimpleText := 'Record changes cancelled for ' + DataSet.Name; end; procedure TForm1.Button2Click(Sender: TObject); begin Table1.Cancel; end; procedure TForm1.Button3Click(Sender: TObject); begin Table1.Post end; procedure TForm1.FormCreate(Sender: TObject); var i: Integer; begin Table1:= TTable.Create(Form1); with Table1 do begin DatabaseName := 'DBDEMOS'; TableType := ttParadox; TableName := 'CustInfo'; Name := 'CustInfo'; Table1.Active := False; { Don't overwrite an existing table } if Table1.Exists then begin Table1.Close; Table1.DeleteTable; end; begin { The Table component must not be active } { First, describe the type of table and give } { it a name } { Next, describe the fields in the table } with FieldDefs do begin Clear; with AddFieldDef do begin Name := 'Field1'; DataType := ftInteger; Required := True; end; with AddFieldDef do begin Name := 'Field2'; DataType := ftString; Size := 30; end; end; { Next, describe any indexes } with IndexDefs do begin Clear; { The 1st index has no name because it is { a Paradox primary key } with AddIndexDef do begin Name := ''; Fields := 'Field1'; Options := [ixPrimary]; end; with AddIndexDef do begin Name := 'Fld2Indx'; Fields := 'Field2'; Options := [ixCaseInsensitive]; end; end; { Call the CreateTable method to create the table } CreateTable; Table1.Active:= True; for i := 1 to 20 do Table1.AppendRecord([i*111, i*222]); end; end; DS2.DataSet:= Table1; DBGrid2.DataSource.DataSet:= Table1; Table1.AfterCancel:= Table1AfterCancel; Table1.Active:= True; end;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|