Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > DB-Aware

Lost Password?

Thread Tools Display Modes
Old 12-27-2001, 01:25 AM
TheDuke TheDuke is offline
Senior Member
Join Date: Jan 2001
Posts: 269
Default How to color bands in a TDBGrid ?


Anybody knows how to color bands in TDBGrid?
I mean color all odd rows with a color other than white.

If you have seen TMSAdvStringGrid grid you know what i'm talking about...
I've already tried TMSAdvDbGrid which have bands but the control is slow as hell (5 times slower than a TDBGrid!!!)
Reply With Quote
Old 12-27-2001, 05:26 AM
MrBaseball34 MrBaseball34 is offline
Senior Member
Join Date: Jan 2001
Posts: 7,260
Default RE: How to color bands in a TDBGrid ?

This works only on datasets that expose the RecNo property. You may need another solution if your database does not.
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
if gdSelected in State then
DBGrid1.Canvas.Brush.Color := clNavy {need that highlight for 'focus'}
else if (DBGrid1.DataSource.DataSet.RecNo mod 2) > 0 then
DBGrid1.Canvas.Font.Color := clWhite;
DBGrid1.Canvas.Brush.Color := clTeal;
DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 10:10 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.