Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

row color in a DbGrid

Posted on 2002-05-03
3
Medium Priority
?
283 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
[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
3 Comments
 
LVL 4

Accepted Solution

by:
nestorua earned 200 total points
ID: 6988712
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
ID: 6989251
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
ID: 9004590
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

650 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