Aftershock
Aftershock

Reputation: 5351

How would you change the colour of the current selection in cxGrid?

How would you change the colour of the current selection in cxGrid?

Thank you.

Upvotes: 2

Views: 7875

Answers (1)

avenmore
avenmore

Reputation: 2885

You could assign a style to the selection by expanding the grid's view's "Styles" property and creating a new style in (a new) style repository for the "Selection" style. Double-click on the style repository component that gets created on your form to set the style's properties.

For more control you can implement the grid's view's "OnCustomDrawCell" event and set the colors there.

procedure TForm1.cxGrid1DBTableView1CustomDrawCell(
  Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
  AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
begin
  if(AViewInfo.Selected) and (Screen.ActiveControl = Sender.Site) then begin
    ACanvas.Brush.Color := clGreen;
    ACanvas.Font.Color := clFuchsia;
  end;
end;

Upvotes: 4

Related Questions