unit LinkDataForm;

interface
{$I AnyLib.Inc}
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  BaseForm, AnyPrint, AnyGrids, ComCtrls, Buttons, ExtCtrls{$IFDEF Delphi5},
  ADODB,DB{$ENDIF};

type
  TfrmLinkData = class(TfrmBase)
    procedure FormCreate(Sender: TObject);
    procedure AnyGridDrawCellColor(Sender: TObject; Row, Col: Integer;
      var BKColor: TColor);
  private
    { Private declarations }
    {$IFDEF Delphi5}
    FDataSource:TDataSource;
    FADOQuery:TADOQuery;
    {$ENDIF}
  public
    { Public declarations }
  end;

var
  frmLinkData: TfrmLinkData;

implementation

{$R *.DFM}

procedure TfrmLinkData.FormCreate(Sender: TObject);
{$IFDEF Delphi5}
var
  i:integer;
{$ENDIF}  
begin
  inherited;
  {$IFDEF Delphi5}
  FDataSource:=TDataSource.Create(Self);
  FADOQuery:=TADOQuery.Create(Self);
  FADOQuery.ConnectionString:=Format('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%sdb.mdb;Persist Security Info=False',
    [ExtractFilePath(Application.ExeName)+'Chinese\']);
  FADOQuery.SQL.Text:='select * from Orders';
  FADOQuery.Open;
  FDataSource.DataSet:=FADOQuery;
  for i:=0 to AnyGrid.Cols-1 do
  begin
    AnyGrid.Columns(i).Title.Caption:=FADOQuery.Fields[i].FullName;
    AnyGrid.Columns(i).FieldName:=FADOQuery.Fields[i].FieldName;
  end;
  AnyGrid.DataSource:=FDataSource;
  {$ENDIF}
end;

procedure TfrmLinkData.AnyGridDrawCellColor(Sender: TObject; Row,
  Col: Integer; var BKColor: TColor);
begin
  if (Row mod 2)=1 then
    BKColor:=RGB(241, 247, 252)
  else
    BKColor:=clWhite;
end;

end.
 