Marco Web Center |
Home: Code Repository: Mastering Delphi 5Project DBGRIDCOL
Project StructureDBGRIDCOL.DPRprogram DBGridCol; uses Forms, dbcolform in 'dbcolform.pas' {Form1}; {$R *.RES} begin Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run; end. DBCOLFORM.PASunit dbcolform; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Grids, DBGrids, DB, DBTables; type TForm1 = class(TForm) Table1: TTable; DataSource1: TDataSource; DBGrid1: TDBGrid; Label1: TLabel; procedure DBGrid1ColEnter(Sender: TObject); procedure DataSource1DataChange(Sender: TObject; Field: TField); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} type TFake = class (TDBGrid); procedure TForm1.DBGrid1ColEnter(Sender: TObject); begin Label1.Caption := Format ( 'Column: %2d; Row: %2d', [TFake (DbGrid1).Col, TFake (DbGrid1).Row]); end; procedure TForm1.DataSource1DataChange(Sender: TObject; Field: TField); begin DBGrid1ColEnter (sender); end; end. DBCOLFORM.DFMobject Form1: TForm1 Left = 143 Top = 153 Width = 502 Height = 279 Caption = 'DB Grid Col' Font.Charset = DEFAULT_CHARSET Font.Color = clBlack Font.Height = -13 Font.Name = 'MS Sans Serif' Font.Style = [] PixelsPerInch = 96 TextHeight = 16 object Label1: TLabel Left = 8 Top = 8 Width = 3 Height = 16 end object DBGrid1: TDBGrid Left = 8 Top = 24 Width = 473 Height = 209 DataSource = DataSource1 TabOrder = 0 TitleFont.Charset = DEFAULT_CHARSET TitleFont.Color = clBlack TitleFont.Height = -13 TitleFont.Name = 'MS Sans Serif' TitleFont.Style = [] OnColEnter = DBGrid1ColEnter end object Table1: TTable Active = True DatabaseName = 'DBDEMOS' TableName = 'COUNTRY.DB' Left = 144 Top = 64 end object DataSource1: TDataSource DataSet = Table1 OnDataChange = DataSource1DataChange Left = 144 Top = 112 end end
|
||
© Copyright Marco Cantù, 1995-2020, All rights reserved |