Re: Color row of DBGrid



Would you share what you have done or give guidance on how to do it ?

"Fons" <fonzzzNO@xxxxxxxxxxxxxxxxxxx> ha scritto nel messaggio
news:468ab710$0$336$e4fe514c@xxxxxxxxxxxxxxxxx

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.


.