Solved

Coloring every other DBGrid row

Posted on 2004-08-23
1
277 Views
Last Modified: 2010-04-04
Hi,

I made a program in Delphi 6 which uses the DBgrid and ADOQuery for SQL statements.
I was wondering how can you color every other row in the DBGrid, meaning coloring every row
1-3-5-7-9...etc.
I read the tutorial about this on http://delphi.about.com/library/weekly/aa031699.htm, but this
tutorial doesn't explain how to do this.

thnx.
0
Comment
Question by:pketeldijk
1 Comment
 
LVL 13

Accepted Solution

by:
BlackTigerX earned 125 total points
ID: 11873247
in the OnDrawColumnCell event of your DBGrid put something like this:

procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
  if (Odd(DBGrid1.DataSource.DataSet.RecNo)) then
    DBGrid1.Canvas.Brush.Color:=clGray //color 1
  else
    DBGrid1.Canvas.Brush.Color:=clMaroon; //color 2
  DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question