| View previous topic :: View next topic |
| Author |
Message |
Chris Guest
|
Posted: Tue Oct 14, 2003 4:14 am Post subject: How to create colored rows in DBGrid |
|
|
Hi
I have tried using the OnDrawColumnCell event to color each row of the
record based on the record in the database. But the only problem i have is
that the data does not have any color. DefaultDrawing property is FALSE.
Can anyone advise how to perform this feature?
Thanks
Chris
|
|
| Back to top |
|
 |
Lucio Fiore Guest
|
Posted: Tue Oct 14, 2003 7:56 am Post subject: Re: How to create colored rows in DBGrid |
|
|
"Chris" <cchuah (AT) tycoint (DOT) com> ha scritto nel messaggio
news:3f8b780f (AT) newsgroups (DOT) borland.com...
| Quote: | Hi
I have tried using the OnDrawColumnCell event to color each row of the
record based on the record in the database. But the only problem i have is
that the data does not have any color. DefaultDrawing property is FALSE.
Can anyone advise how to perform this feature?
Thanks
Chris
|
procedure dbgRisultatiDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
// DefaultDrawing property of the grid is FALSE
// Set the font properties for the current cell
dbgRisultati.Canvas.Font.Pitch := fpFixed;
dbgRisultati.Canvas.Font.Name := 'Courier';
dbgRisultati.Canvas.Font.Color := clBlue;
//
// Set the color of the row (in this case i have the property
dgRowSelect = True)
if gdSelected in State then
dbgRisultati.Canvas.Brush.Color := clHighlight
Else
dbgRisultati.Canvas.Brush.Color := clMoneyGreen;
End;
//
// Draw the cel
dbgRisultati.Canvas.FillRect(rect);
//
// Draw the text into the cell
dbgRisultati.Canvas.TextOut(Rect.Left + 2, Rect.Top + 2, sTesto);
//
end;
I Hope it's what you need
Lucio Fiore
|
|
| Back to top |
|
 |
|