Solved

row color in a DbGrid

Posted on 2002-05-03
3
272 Views
Last Modified: 2010-04-04
How can I put an specific color in a selected row in a DBGRid?

thanks in advance.

sincerly

  AFM.

0
Comment
Question by:AngelFireMateo
3 Comments
 
LVL 4

Accepted Solution

by:
nestorua earned 50 total points
Comment Utility
HI,
Paste you my comment to Spk2000ar for sthe similar question.
1.Set the DefaultDrawing property of your DBGrid to True.
In OnDrawColumnCell event write the following:

procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column:
TColumn; State: TGridDrawState);
var OldBrush, OldFont: TColor;
begin
with Sender as TDBGrid do
 with Canvas do
  begin
    OldBrush:=Brush.Color;
     OldFont:=Font.Color;
//here goes your condition for highlighting:
  if (DataSource.DataSet[YourFieldName]=0)
   then
    begin
     if gdSelected in State
      then
       begin
        Brush.Color:=clRed;
         Font.Color:=clAqua;
       end
      else
       begin
        Brush.Color:=$00DDDFFF;
         Font.Color:=clBlack;
       end;
      end;
//
   DefaultDrawColumnCell(Rect, DataCol, Column, State);
//
    Brush.Color:=OldBrush;
     Font.Color:=OldFont;
end;

Sincerely,
Nestorua.  
0
 
LVL 2

Expert Comment

by:freshman3k
Comment Utility
Hello,

Also, This Borland Community Article has a good explanation.

http://community.borland.com/article/0,1410,20845,00.html
0
 
LVL 1

Expert Comment

by:pnh73
Comment Utility
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept answer from nestorua

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Paul (pnh73)
EE Cleanup Volunteer
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

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…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 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