Board index » delphi » painting a DBCtrlGrid

painting a DBCtrlGrid

I need to paint a DBCtrlGrid different colors under different conditions.
I.E.  I need to show the selected record in a highlight color, and the rest
of the grid another color when I am performing an operation such as Drag &
Drop Etc.  I also need to paint the entire grid the same color if the
operation is finished.  Some sort of Boolean I suppose.  The code I am
currently using to paint the grid id below.  I need to add the extra steps
to return it to one color as needed.  I can't seem to get it to "repaint'
when the boolean changes.  Can someone offer a suggestion please.  :-)

Sample Code:
==============================================================
procedure TForm1.DBCtrlGrid1PaintPanel(DBCtrlGrid: TDBCtrlGrid;
  Index: Integer);
  var I: Integer;
    begin
       with DBCtrlGrid1 do
           // Set colors of DBCtrlGrid
          begin
             I:=PanelIndex;
           if (Index=I) then
             Canvas.brush.color:=$0060FF60
           else
             Canvas.brush.color:=$00F47A00;
             Canvas.FillRect(Rect(0,0,panelwidth,panelheight));
         end
   end;

T.G.

 

Re:painting a DBCtrlGrid


Quote
>  I can't seem to get it to "repaint'
> when the boolean changes.  Can someone offer a suggestion please.  :-)

Hmm.. you might try calling TDBCtrlGrid.Repaint from the
MyBooleanField.OnChange

=Bill=

Other Threads