I want to change the color of selected records (marked check boxes) and focused record in a TcxGrid by different colors.
-
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 White2 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.– Holy Thirteen2 days ago
Add a comment
|
1 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.