unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, StdCtrls, Buttons, DB, ADODB;
type
TNDBGrid = Class(TDBGrid)
protected
procedure ColWidthsChanged; override;
//procedure AdjustSize(Index, Amount: Longint; Rows: Boolean); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
type
TForm1 = class(TForm)
DBGrid1: TDBGrid;
BitBtn1: TBitBtn;
ADOQuery1: TADOQuery;
DataSource1: TDataSource;
procedure DBGrid1ColumnMoved(Sender: TObject; FromIndex,
ToIndex: Integer);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.DBGrid1ColumnMoved(Sender: TObject; FromIndex,
ToIndex: Integer);
begin
ShowMessage('Moved!')
end;
{ NDBGrid }
procedure TNDBGrid.ColWidthsChanged;
var
Column: TColumn;
begin
inherited;
Column := Self.Columns[self.SelectedIndex];
if Column <> nil then
ShowMessage(Column.Title.Caption);
end;
constructor TNDBGrid.Create(AOwner: TComponent);
begin
inherited;
end;
destructor TNDBGrid.Destroy;
begin
inherited;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
AGrid: TNDBGrid;
column: TColumn;
begin
AGrid := TNDBGrid.Create(Self);
AGrid.DataSource := DataSource1;
AGrid.Parent := Self;
{column := AGrid.Columns.Add;
column.Title.Caption := 'test';
column := AGrid.Columns.Add;
column.Title.Caption := 'move';
column := AGrid.Columns.Add;
column.Title.Caption := 'width';
}
end;
end.