How to change line color in TMSFNCGrid

Hello, Iam new with TMS FNC Components and I am trying to change the line color according to its column value.. I have a column called Status and it could be A or I. For status 'A' I would like to set whole line color to Green and for 'I', yellow.. and all other status would keep default line color.. 


I am coming from TDbGrid and I usually uses the 'DrawColumnCell' event to acomplish it.. However, with TMSFNCGrid we dont have this event..

How can I do it?

Thanks!!
Renato

Hi,


In TTMSFNCGrid you can use the OnCellBeforeDraw and OnCellAfterDraw events

Hello..


Would you mind in giving me a small code example?

Thanks!
Renato

Can you provide us the original code that you have used in TDBGrid? Then we can see if we can convert it to FNC compatible code

Yes.. On TDbGrid we can use either OnPrepareCanvas or OnDrawColumnCell.. In my case.. I used OnDrawColumnCell.


procedure TFrmOrder.DbGridOrderDrawColumnCell(Sender : TObject; const Rect : TRect; DataCol : Integer; Column : TColumn; State : TGridDrawState);
begin
if DsOrder.DataSet.FieldByName('pve_status').Asstring = 'A' then
begin
DbGridOrder.Canvas.Brush.Color := $00F3F5F5;   // background color wanted
DbGridOrder.Canvas.Font.Color := $00457E45;   //font color
//DbGridOrder.Canvas.TextStyle.Alignment:=taCenter    // another tip to center the text in the cell
end;
   DbGridOrder.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;  

To style the cell background/font you can use the OnGetCellLayout event. This event allows you to access all the appearance/style information of the cell:



procedure TForm1.TMSFNCGrid1GetCellLayout(Sender: TObject; ACol, ARow: Integer;
  ALayout: TTMSFNCGridCellLayout; ACellState: TTMSFNCGridCellState);
begin
  ALayout.Fill.Color := gcRed;
  ALayout.Font.Color := gcWhite;
end;

Thanks for the answer.. could you give me an example how to change the color based on the current column value?

I mean.. 

If the column Status equals 'A' then  // <<<<< I dont know how to compare like I do on DbGrid..
ALayout.Fill.Color := gcRed;
 ALayout.Font.Color := gcWhite;
else
ALayout.Fill.Color := gcblue;
 ALayout.Font.Color := gcWhite;

Thanks..

You can simply take over the same line I suppose?



if DsOrder.DataSet.FieldByName('pve_status').Asstring = 'A' then