How to change the color of focused and selected rows in DevExpress TcxGrid using different colors?

265 Views Asked by At

I want to change the color of selected records (marked check boxes) and focused record in a TcxGrid by different colors.

1

There are 1 best solutions below

0
Holy Thirteen On BEST ANSWER

You can do this using the code below:

procedure TMyForm.cxGrid1DBTableView1CustomDrawCell(
  Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
  AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
begin
  if AViewInfo.GridRecord.Focused then
    ACanvas.Brush.Color := clBlue;

  if AViewInfo.GridRecord.Selected then
    ACanvas.Brush.Color := clGreen;
end;

if you want to change the color of just cell instead of the whole row, you can do it by removing .GridRecord expression after AviewInfo.