ADO Database Delphi

Title: DBGrid ListPaper
Question: How can I change my DBGird look?
Answer:
unit RVDBGrid;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids, DBGrids;
const
DefaultOddColor = clWindow;
DefaultEvenColor = $00F8FFC6;
type
TRVDBGrid = class(TDBGrid)
private
FOddColor: TColor;
FEvenColor: TColor;
procedure SetOddColor(const Value: TColor);
procedure SetEvenColor(const Value: TColor);
protected
procedure DrawColumnCell(const Rect: TRect; DataCol: Integer;
Column: TColumn; State: TGridDrawState); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property OddColor: TColor read FOddColor write SetOddColor default DefaultOddColor;
property EvenColor: TColor read FEvenColor write SetEvenColor default DefaultEvenColor;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Rendez-vous (DB)', [TRVDBGrid]);
end;
{ TRVDBGrid }
constructor TRVDBGrid.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FOddColor := DefaultOddColor;
FEvenColor := DefaultEvenColor;
end;
destructor TRVDBGrid.Destroy;
begin
inherited Destroy;
end;
procedure TRVDBGrid.DrawColumnCell(const Rect: TRect; DataCol: Integer;
Column: TColumn; State: TGridDrawState);
var
LeftPos: Integer;
begin
inherited;
if DataLink.ActiveRecord mod 2 = 0 then Canvas.Brush.Color := FEvenColor
else Canvas.Brush.Color := FOddColor;
if Column.Color Color then
if Column.Color Canvas.Brush.Color then Canvas.Brush.Color := Column.Color;
if gdSelected in State then
begin
Canvas.Font.Color := clHighLightText;
Canvas.Brush.Color := clHighLight;
end;
Canvas.FillRect(Rect);
if not Column.Field.IsNull then
begin
if Column.Alignment = taCenter then
LeftPos := Rect.Left + ((Rect.Right - Rect.Left) - Canvas.TextWidth(Column.Field.Value))
else
LeftPos := Rect.Left + 2;
Canvas.TextRect(Rect,LeftPos,Rect.Top+ 2,Column.Field.Value);
end;
end;
procedure TRVDBGrid.SetEvenColor(const Value: TColor);
begin
FEvenColor := Value;
Paint;
end;
procedure TRVDBGrid.SetOddColor(const Value: TColor);
begin
FOddColor := Value;
Paint;
end;
end.