unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Data.DB, Data.Win.ADODB, NxGridView6, NxColumns6, NxControls6, NxCustomGrid6,
  NxVirtualGrid6, NxDBGrid6, NxDBColumns6, Vcl.StdCtrls, Vcl.ExtCtrls, Vcl.DBCtrls, Vcl.ImgList, Vcl.Mask;

type
  TForm1 = class(TForm)
    DataSource1: TDataSource;
    ADOConnection1: TADOConnection;
    ADOTable1: TADOTable;
    NextDBGrid61: TNextDBGrid6;
    NxReportGridView61: TNxReportGridView6;
    Button1: TButton;
    DBNavigator1: TDBNavigator;
    ImageList1: TImageList;
    DBEdit1: TDBEdit;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure NextDBGrid61FieldAdded(Sender: TObject; Field: TField; Column: TNxColumn6);
    procedure NextDBGrid61AddFieldQuery(Sender: TObject; Field: TField; var ColumnClass: TNxColumnClass;
      var Accept: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
	SourceStr: string;
begin
  SourceStr := ExtractFilePath(ParamStr(0)) + 'Data\data.mdb';
  ADOConnection1.Close;
  ADOConnection1.ConnectionString :=	'Provider=Microsoft.Jet.OLEDB.4.0;' +
  																		'User ID=Admin;' +
                                      'Data Source=' + SourceStr + ';' +
                                      'Mode=ReadWrite;Extended Properties="";' +
                                      'Jet OLEDB:System database="";' +
                                      'Jet OLEDB:Registry Path="";' +
                                      'Jet OLEDB:Database Password="";' +
                                      'Jet OLEDB:Engine Type=5;' +
                                      'Jet OLEDB:Database Locking Mode=1;' +
                                      'Jet OLEDB:Global Partial Bulk Ops=2;' +
                                      'Jet OLEDB:Global Bulk Transactions=1;' +
                                      'Jet OLEDB:New Database Password="";' +
                                      'Jet OLEDB:Create System Database=False;' +
                                      'Jet OLEDB:Encrypt Database=False;' +
                                      'Jet OLEDB:Don' + Char(39) + 't Copy Locale on Compact=False;' +
                                      'Jet OLEDB:Compact Without Replica Repair=False;' +
                                      'Jet OLEDB:SFP=False';
  ADOConnection1.Open;
  ADOTable1.Open;
  ADOTable1.Sort := '[ID]';
  TButton(Sender).Enabled := False;
  NextDBGrid61.DataSource := DataSource1;
  DBEdit1.DataField := 'FirstName';
  NxReportGridView61.FixedColCount := 2;
end;

procedure TForm1.NextDBGrid61AddFieldQuery(Sender: TObject; Field: TField; var ColumnClass: TNxColumnClass;
  var Accept: Boolean);
begin
  if Field.FullName = 'IconIndex' then
  begin
    ColumnClass := TNxDBIconColumn6;
  end;
end;

procedure TForm1.NextDBGrid61FieldAdded(Sender: TObject; Field: TField; Column: TNxColumn6);
begin
  if Field.FieldName = 'ID' then
  begin
    if Column is TNxNumberColumn6 then
    begin
      with Column as TNxDBNumberColumn6 do
      begin
        Precision := 0;
        Width := 40;
      end;
    end;
  end;
  if Column is TNxDBMemoColumn6 then
  begin
    TNxDBMemoColumn6(Column).ExpandContent := True;
  end;
  if Column is TNxDBIconColumn6 then
  begin
    Column.Alignment := taCenter;
    Column.Header.Caption := 'Icon';
    Column.Width := 40;
    Column.Position := 1;
    TNxDBIconColumn6(Column).Images := ImageList1;
  end;
end;

end.
