Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > DB-Aware

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 01-09-2002, 10:58 AM
FreakAzoid FreakAzoid is offline
Senior Member
 
Join Date: Jan 2001
Posts: 614
Default dbgrid line color

I want to changed the color of the lines in the dbgrid.


Thanks...
Reply With Quote
  #2  
Old 01-09-2002, 11:46 AM
Mucan Mucan is offline
Senior Member
 
Join Date: Feb 2001
Posts: 121
Default RE: dbgrid line color

try this;
------------
On my mainform (MAINFORM in MAINUNIT) I have
a dbgrid called SHOWGRID and
a variable called COLORFLAG : boolean and
a event handling function

procedure Tmainform.showgridDrawColumnCell
(Sender: TObject; const Rect: TRect; DataCol: Integer;
Column: TColumn; State: TGridDrawState);
begin
with (sender as tdbgrid) do
begin
if DataSource.DataSet.recno mod 2 = 0
then mainunit.colorflag := true
else mainunit.colorflag := false;

if mainunit.colorflag
then Canvas.Brush.Color := $00F8FFC6
else Canvas.Brush.Color := clwhite;

Canvas.font.Color := font.color;
DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
end;

To make clearer what is done, here the event
handling before cleaning up the code:

procedure Tmainform.showgridDrawColumnCell
(Sender: TObject; const Rect: TRect; DataCol: Integer;
Column: TColumn; State: TGridDrawState);
begin
if showgrid.DataSource.DataSet.recno mod 2 = 0)
then mainunit.colorflag := true
else mainunit.colorflag := false;

if mainunit.colorflag
then showgrid.Canvas.Brush.Color := $00F8FFC6
else showgrid.Canvas.Brush.Color := clwhite;
// $00F8FFC6 is that looking green

showgrid.Canvas.font.Color := showgrid.font.color ;
showgrid.DefaultDrawColumnCell(Rect, DataCol, Column, State);}
end ; }
Reply With Quote
  #3  
Old 01-09-2002, 12:32 PM
FreakAzoid FreakAzoid is offline
Senior Member
 
Join Date: Jan 2001
Posts: 614
Default RE: dbgrid line color

I have already changed the color of the canvas. what i want to chenge is the color of the actaul lines that is drawn between the columns and rows.

Thanks...
Reply With Quote
  #4  
Old 01-10-2002, 06:22 AM
MrBaseball34 MrBaseball34 is offline
Senior Member
 
Join Date: Jan 2001
Posts: 7,260
Default RE: dbgrid line color

You have to override the paint method and change the
LineColor variable sent to the DrawLines method at line 1784 in Grids.pas.
Reply With Quote
  #5  
Old 01-10-2002, 06:23 AM
MrBaseball34 MrBaseball34 is offline
Senior Member
 
Join Date: Jan 2001
Posts: 7,260
Default RE: dbgrid line color

Since it is a local variable, and the DrawLines method is also local, you practically have to copy the full Paint
method from TCustomGrid.Paint and not call inherited.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:19 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.