views:

95

answers:

1

Hi,

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

Thank you.

+3  A: 

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;
avenmore