Re: Color row of DBGrid
- From: Fons <fonzzzNO@xxxxxxxxxxxxxxxxxxx>
- Date: Tue, 03 Jul 2007 22:53:23 +0200
I change color of the 'current' record in a DBGrid using the
OnDrawColumnCell eventi with the following code:
if (gdFocused in State) or (gdSelected in State) then
begin
if BtnMod.Down then
MyDBGrid.Canvas.Brush.Color := clYellow
else
MyDBGrid.Options := DelegheDBGrid.Options + [dgRowSelect];
MyDBGrid.DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
The problem I have is that it doesn't work exactly as I wanted. The first
time I show the DBGrid no record are hilighted though dgRowSelect is true.
Clicking on the BtnMod the focused row is correctly painted in yellow, since
dgRowSelect is true. But I need dgRowSelect to be false to edit the record
and if it is set to false, the cells are not painted in yellow.
I think you should do ALL the drawing of the cells in OnDrawColumnCell. I have written a program with a grid with user-chosen colors, crosses in colored cells etc. Most of the standard drawing, not different from a standard grid is simple; that's not too much work.
I think it doesn't work with just changing the Brush.Color and the Options.
Thanks in advance for any suggestions.
Fons.
.
- Follow-Ups:
- Re: Color row of DBGrid
- From: FrancoJommi
- Re: Color row of DBGrid
- Prev by Date: Re: Working with windows handles
- Next by Date: Re: Delphi 2005 .NET support
- Previous by thread: Working with windows handles
- Next by thread: Re: Color row of DBGrid
- Index(es):