0

I use the event OnCustomDrawCell of TcxGridDBDataController to change the font row color of a DevExpress TcxGrid to red if a certain Field of the displayed record (e.g 'Debit' has value 1)

if Sender.DataController.GetValue(AViewInfo.GridRecord.RecordIndex, 15) = 1 then
   begin

    ACanvas.Font.Color := clRed;
   end;

The above code works if field 'Debit' has recordIndex 15. But if I change the order of fields it stops working (because recordindex is not 15 anymore).

Instead of Recordindex I would like to use the fieldname 'Debit' in order to check the value.

I would be grateful of someone could help change the above code so that it works regardless of the position of field 'Debit'.

Thank you

1 Answers1

0

It's ok I found it out : Here's the code doing this

{

procedure TfrmAirReservs.grdReservsListDBTableView1CustomDrawCell(
  Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
  AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
  var Debit: TcxGridDBColumn;
begin

  Debit := TcxGridDBTableView(Sender).GetColumnByFieldName('Debit');
  if AViewInfo.GridRecord.Values[Debit.Index] = 1 then
   begin

    ACanvas.Font.Color := clRed;
   end;
end;

}