Holy Thirteen
Holy Thirteen

Reputation: 338

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

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

Upvotes: -1

Views: 571

Answers (1)

Holy Thirteen
Holy Thirteen

Reputation: 338

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.

Upvotes: 1

Related Questions