-1

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

2
  • Questions that are written to be self-answered are still required to meet the same quality standards as any other question here. You may want to review How to Ask.
    – Ken White
    2 days ago
  • @KenWhite Thanks for taking time to review the post, I reviewed my question according to "How to Ask" post, and made changes in Title. I think the question itself meets the quality standards, but if you don't think so I'll be happy to know. 2 days ago

1 Answer 1

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.