Solved

Coloring every other DBGrid row

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 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

17 Experts available now in Live!

Get 1:1 Help Now