Solved

Coloring every other DBGrid row

Posted on 2004-08-23
1
281 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month11 days, 5 hours left to enroll

628 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