home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / AddOns / Components / TEECHART / Delphi1_And_Delphi2 / EXAMPLES / DATABASE / UEDITAB.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-10-24  |  1.7 KB  |  73 lines

  1. unit ueditab;
  2.  
  3. interface
  4.  
  5. uses
  6.   Wintypes, Winprocs, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   TeEngine, Series, TeeProcs, Chart, DBChart, ExtCtrls, DBCtrls, Grids,
  8.   DBGrids, Db, DBTables, StdCtrls;
  9.  
  10. { This example shows how to allow Table editing while the Chart
  11.   refreshes new table contents, and the current record is preserved.
  12.  
  13.   By default, Series components connected to Tables
  14.   ( Series1.DataSource := Table1 )
  15.  
  16.   refresh themselves when the Table is edited.
  17.  
  18.   But, the current record is not preserved.
  19.   To keep the current record position, you should create a "BookMark",
  20.   using the Table OnBeforeEdit event.
  21.  
  22.   Then, at Table OnAfterPost event you can use the bookmark to
  23.   repositionate the current record.
  24.  
  25. }
  26.  
  27. type
  28.   TEditTableForm = class(TForm)
  29.     Table1: TTable;
  30.     DataSource1: TDataSource;
  31.     DBGrid1: TDBGrid;
  32.     DBChart1: TDBChart;
  33.     Series1: TBarSeries;
  34.     Panel1: TPanel;
  35.     DBNavigator1: TDBNavigator;
  36.     Label1: TLabel;
  37.     Panel2: TPanel;
  38.     Label2: TLabel;
  39.     Button1: TButton;
  40.     procedure Button1Click(Sender: TObject);
  41.     procedure Table1AfterPost(DataSet: TDataset);
  42.     procedure Table1BeforeEdit(DataSet: TDataset);
  43.   private
  44.     { Private declarations }
  45.   public
  46.     { Public declarations }
  47.     bb:TBookMark;
  48.   end;
  49.  
  50. implementation
  51.  
  52. {$R *.DFM}
  53.  
  54. procedure TEditTableForm.Button1Click(Sender: TObject);
  55. begin
  56.   Close;
  57. end;
  58.  
  59. procedure TEditTableForm.Table1AfterPost(DataSet: TDataset);
  60. begin
  61.   { go to current record... }
  62.   Table1.GotoBookMark(bb);
  63.   Table1.FreeBookMark(bb);
  64. end;
  65.  
  66. procedure TEditTableForm.Table1BeforeEdit(DataSet: TDataset);
  67. begin
  68.   { get current record... }
  69.   bb:=Table1.GetBookMark;
  70. end;
  71.  
  72. end.
  73.