Solved

Coloring every other DBGrid row

Posted on 2004-08-23
1
276 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

895 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now