Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Coloring every other DBGrid row

Posted on 2004-08-23
1
Medium Priority
?
282 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 500 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

670 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