Solved

Change Cell Color

Posted on 1998-12-31
1
268 Views
Last Modified: 2010-04-04
I know this question has been asked before but I don't have the time to search the 4000 previous questions.
I need to change the color of one cell in a DBGrid depending on what data is in the cell. If it is 'Y' i need the cell to be Red, else white. I don't want to change the whole coloumn. I know how to do that. i just want to change the one cell, or multiple cells if there is more than one record that has 'Y' for that field.
Thanks
bozo
0
Comment
Question by:bozo7
1 Comment
 
LVL 1

Accepted Solution

by:
adeng earned 100 total points
ID: 1353954
first set DBGrid 'Default Drawin' property to False and write this code on DrawColumnCell :

procedure TfrmPenjualan.JurnalGridDrawColumnCell(Sender: TObject;
          const Rect: TRect; DataCol: Integer; Column: TColumn;
          State: TGridDrawState);
begin
     with DataModule1 do
          if  (qryItemPenjualanJUMLAH.Value > 20 ) then
               JurnalGrid.Canvas.Font.COLOR := clRed;

     JurnalGrid.DefaultDrawColumnCell(Rect, DataCol, Column, State);        
end;

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

680 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