Board index » delphi » Hard DBGrid Question (Hard for me anyway).

Hard DBGrid Question (Hard for me anyway).

I have a Paradox table with a True/False field.  I would like to display
something special though instead of True/False.  My initial thought
would be to BOLD the entire row for a True value (in my case) or normal
for False.  Does anyone have such a thing?  Or can anyone help me modify
the VCL source to make it?  I would put it in the public domain if
someone were to help.

If this is too hard then I would be willing to settle for Check Box.  I
believe that I saw some sample code in a newsgroup, but don't remember
which one.

As a side question, I was using the Database Desktop to create the table
and in the Help it implied that using Paradox I could get a True/False
field to say Yes/No instead. Did I understand that right?  If so,
shouldn't there be some kind of code that I could do the same thing?

Thanks
Peter

 

Re:Hard DBGrid Question (Hard for me anyway).


The simplest method is to:
        1: set "DefaultDrawing"  to FALSE in the DBGrid properties
        2: in the DBGrid Events tab, Double-Click "OnDrawDataCell"
        3: enter the following code:
  with TDBGrid(Sender).Canvas do begin
    if
TDBGrid(Sender).DataSource.DataSet.FieldByName('fld2').AsBoolean then
      Font.Color:=clLime else
      Font.Color:=clRed;
    FillRect(Rect);
    TextOut(Rect.Left, Rect.Top,Field.AsString);
  end;

This should display all rows having "fld2" TRUE in Green, FALSE in
Red...

This is an intended and expected use of DBGrid.  Good Luck!!

On Fri, 19 Dec 1997 22:28:39 -0600, Peter Chang <pch...@dakota.net>
wrote:

Quote
>I have a Paradox table with a True/False field.  I would like to display
>something special though instead of True/False.  My initial thought
>would be to BOLD the entire row for a True value (in my case) or normal
>for False.  Does anyone have such a thing?  Or can anyone help me modify
>the VCL source to make it?  I would put it in the public domain if
>someone were to help.

>If this is too hard then I would be willing to settle for Check Box.  I
>believe that I saw some sample code in a newsgroup, but don't remember
>which one.

>As a side question, I was using the Database Desktop to create the table
>and in the Help it implied that using Paradox I could get a True/False
>field to say Yes/No instead. Did I understand that right?  If so,
>shouldn't there be some kind of code that I could do the same thing?

>Thanks
>Peter

Re:Hard DBGrid Question (Hard for me anyway).


Hi Peter,

Quote
>As a side question, I was using the Database Desktop to create the table
>and in the Help it implied that using Paradox I could get a True/False
>field to say Yes/No instead. Did I understand that right?  If so,
>shouldn't there be some kind of code that I could do the same thing?

Check out property DisplayValues of your TBooleanField in your TTable or
TQuery component. If you set it to 'Yes;No'  it will display these strings
instead of the True and False.
Regards, Ron Veerman.

Other Threads