What about an alternative approch.  Create a calculated string field.  Use
the OnCalcFields event to fill that field with 'YES' or 'NO' depending on
the value of field DateOut.  Use the dbGrid to display the value in the new
calculated field.

Guy 

-----Original Message-----
From: John Christenhusz [mailto:[EMAIL PROTECTED]]
Sent: Monday, 15 October, 2001 4:54 p.m.
To: Multiple recipients of list delphi
Subject: [DUG]: dbGrid


G'day folks,

I've asked this question before and did get a satisfactory reply at that
time, but after all it doesn't seem to work the way I want it to.

What I want is to change the presentation of a dbGrig's field only when the
field ('Type') = 2.

Pseudo code:
When Type = 2 then
begin
  when field DateOut >= now then
    show a string 'YES'
  else
    show a string 'NO'
end


This works fine for the very first presentation. But when I scroll down
(removing the top records with a 'YES') and then up again, then the records
with a 'YES' have changed to 'NO'. For some reason the
dbgridSearchDrawDataCell event doesn't seem to correspond with the actual
data.


The code I use is:

procedure TformREDB.dbgridSearchDrawDataCell(Sender: TObject; const Rect:
TRect; Field: TField; State: TGridDrawState);
begin
  if (field.name = 'tblClientType') then
  begin
    if tblClientType.asInteger = 2 then
      if tblClientDateOut.asDateTime >= now then
        dbgridSearch.Canvas.textOut(rect.left + 5,  rect.top + 1, 'Yes');
       else
        dbgridSearch.Canvas.textOut(rect.left + 5,  rect.top + 1, 'No');


Any ideas???

TIA




---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to