Subject TIB_CtrlGrid(OnPaint)
Author angusbreno
Hello,

I'm having a problem to paint a canvas in a TIB_CtrlGrid.
I need to paint a color on the left side of the box when a particular field is of particular value.

example:

RECNO | Status | Color |

1 | 1 Blue
2 | 1 Blue
3 | 3 Green
4 | 2 Red

To do this I'm doing well on the OnPaint event:

TfmPrincipal.gridPedidosPaintPanel procedure (IB_CtrlGrid: TIB_CtrlGrid;
   RowNum: Integer);
begin

case (dmConexao.qrPedidoCompraProduto.BufferFieldByName ('iddcstatus'). AsInteger) of
     1: pPintaStatus.Color: = clPurple;
     3: pPintaStatus.Color: = clMaroon;
     4: pPintaStatus.Color: = clRed;
     5: pPintaStatus.Color: = clTeal;
     6: pPintaStatus.Color: = clBlue;
   end;

   gridPedidos.Canvas.Draw (20, 6, PainelToBitMap (pPintaStatus));

end;

function PainelToBitmap(Panel: TWinControl): TBitmap;
begin
   Result: = TBitmap.Create;

   Result.Width: = Painel.ClientWidth;
   Result.Height: = Painel.ClientHeight;
   Result.Canvas.Lock;
   try
     Painel.PaintTo (Result.Canvas.Handle, 0, 0);
   finally
     Result.Canvas.Unlock;
   end;
end;

This works, but the current row of the record catches the last color painted. How can I solve this detail?

Thank you,
Breno S.