Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Change Cell Color

Posted on 1998-12-31
1
Medium Priority
?
274 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 400 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

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.

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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Loops Section Overview
Suggested Courses

916 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