DbGrid Row Color

Posted on 2008-02-02
Medium Priority
Last Modified: 2012-06-27
Hi All,

I'm using the code snippet below to set a different TEXT color and RECT Background color.
It looks easy, but the text desappears when the RECT is fullfilled.
Even when I change the text color only, it does not change.
I tried to bold the text to force it returns, :-), but nothing. Any tip?


if gdSelected in State then
    DBGrid4.Canvas.Brush.Color := clAqua; // Background color
    DBGrid4.Canvas.Font.Color := clRed; // Font color
    DBGrid4.Canvas.Font.Style := [fsBold];
    DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);

Open in new window

Question by:paulo_psa
  • 2
LVL 13

Expert Comment

ID: 20805086
Firstly make sure the event you are using is onDrawColumnCell

This is what I use and it's all I need:

  if (gdselected in State) then
  dbgrid1.Canvas.Font.Color := clWhite;
  dbgrid1.Canvas.brush.color := clMedGray;

  DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
LVL 13

Accepted Solution

rfwoolf earned 600 total points
ID: 20805089
Take this line:
  DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
out of your if then statement

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

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…
When you have multiple client accounts to manage, it often feels like there aren’t enough hours in the day. With too many applications to juggle, you can’t focus on your clients, much less your growing to-do list. But that doesn’t have to be the cas…
Watch the video to know the simple way to remove or recover or reset lost or forgotten passwords of Outlook PST file. With Kernel Outlook Password Recovery tool such operation is very easy to perform. It is a freeware with limitation to use with 500…

621 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