Board index » delphi » Grid rows/lines color change

Grid rows/lines color change

Is it possible to change the color of lines / rows
in the GRIDs ?
many thanks for both answers. Gianni.
 

Re:Grid rows/lines color change


You can set the lines off in the object inspector,
and then draw them yourself in the onDrawCell event.

Quote
Giovanni Filippini wrote:

> Is it possible to change the color of lines / rows
> in the GRIDs ?
> many thanks for both answers. Gianni.

  Guido.Geurts.vcf
< 1K Download

Re:Grid rows/lines color change


Giovanni,

From the FAQ's which come with Delphi.

Q:   "How do I change the color of a grid cell in a TDBGrid?"

A:   Enter the following code in the TDBGrid's OnDrawDataCell event:

     Procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect:
TRect;
       Field: TField; State: TGridDrawState);
     begin
        If gdFocused in State then
           with (Sender as TDBGrid).Canvas do
           begin
              Brush.Color := clRed;
              FillRect(Rect);
              TextOut(Rect.Left, Rect.Top, Field.AsString);
           end;
     end;

     Set the Default drawing to true.  With this, it only has to draw
the
     highlighted cell.  If you set DefaultDrawing to false, you must
draw all
     the cells yourself with the canvas properties.

Bob
----
Sent using Virtual Access 5.01 - download your freeware copy now
http://www.atlantic-coast.com/downloads/vasetup.exe

Re:Grid rows/lines color change


thanks Bob, also for the useful unit ( jpg_dll ),
sorry for the inaccurate question, but I mean
Vertical/Horizontal Lines  in Grids .
Bye & Thanks.

Re:Grid rows/lines color change


Giovanni,

There is no "off the shelf" method, as far as I can see. I think you
will have to draw the lines your self in an OnDrawDataCell (or
OnDrawColumnCell) handler, as with the example for colouring the cells
I sent earlier.

Bob
---
Sent using Virtual Access 5.01 - download your freeware copy now
http://www.atlantic-coast.com/downloads/vasetup.exe

Other Threads