home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / AddOns / Components / TEECHART / DELPHI3.EXE / %MAINDIR% / Examples / Delphi3 / Virtual DataSet / Udemo2.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1998-11-17  |  2.0 KB  |  79 lines

  1. unit udemo2;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   Grids, DBGrids, Db, TeeData, TeEngine, Series, ExtCtrls, TeeProcs, Chart,
  8.   StdCtrls, DBCtrls, BubbleCh;
  9.  
  10. type
  11.   TForm1 = class(TForm)
  12.     Chart1: TChart;
  13.     SeriesDataSet1: TSeriesDataSet;
  14.     DataSource1: TDataSource;
  15.     Panel1: TPanel;
  16.     DBNavigator1: TDBNavigator;
  17.     Series1: TBubbleSeries;
  18.     Panel2: TPanel;
  19.     DBGrid1: TDBGrid;
  20.     Memo1: TMemo;
  21.     procedure FormCreate(Sender: TObject);
  22.     procedure Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
  23.       Y: Integer);
  24.     procedure Chart1ClickSeries(Sender: TCustomChart; Series: TChartSeries;
  25.       ValueIndex: Integer; Button: TMouseButton; Shift: TShiftState; X,
  26.       Y: Integer);
  27.   private
  28.     { Private declarations }
  29.   public
  30.     { Public declarations }
  31.   end;
  32.  
  33. var
  34.   Form1: TForm1;
  35.  
  36. implementation
  37.  
  38. {$R *.DFM}
  39.  
  40. procedure TForm1.FormCreate(Sender: TObject);
  41. begin
  42.   SeriesDataSet1.Close;
  43.   Series1.FillSampleValues(8);
  44.   SeriesDataSet1.Open;
  45. end;
  46.  
  47. procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
  48.   Y: Integer);
  49. var tmp:Integer;
  50. begin
  51.   if not DBGrid1.EditorMode then  { if not editing in the Grid... }
  52.   begin
  53.     tmp:=Series1.Clicked(x,y);   { if mouse is over a point.... }
  54.     if tmp>=0 then
  55.        SeriesDataSet1.RecNo:=tmp+1;   { go to record where mouse is over }
  56.   end;
  57. end;
  58.  
  59. procedure TForm1.Chart1ClickSeries(Sender: TCustomChart;
  60.   Series: TChartSeries; ValueIndex: Integer; Button: TMouseButton;
  61.   Shift: TShiftState; X, Y: Integer);
  62. var tmp:Integer;
  63. begin
  64.   if Series=Series1 then
  65.   begin
  66.     tmp:=Series1.Clicked(x,y);
  67.     if tmp>=0 then
  68.        SeriesDataSet1.RecNo:=tmp+1;   { if clicked a point... }
  69.     { go to Grid }
  70.     DBGrid1.SetFocus;
  71.     { go to "Y" field in the grid }
  72.     DBGrid1.SelectedField:=SeriesDataSet1.FieldByName('Y');
  73.     { start editing }
  74.     DBGrid1.EditorMode:=True;
  75.   end;
  76. end;
  77.  
  78. end.
  79.