cxGrid selection - avoid selecting one particular column

3.5k views Asked by At

When you select a row in the cxGrid, the entire row gets selected (changes color to blue). How can I tell the grid not to select the records from a certain column i.e leave it colorless ? I tried afterscroll of the dataset to use :

cxGrid1dbTableView1.GetColumnByFieldName('MYFIELD').Focused := True;

But does not work.....

1

There are 1 answers

7
Stefan Glienke On

Use the OnCustomDrawCell event of the columns you want to change and put this code inside:

if AViewInfo.Selected then
begin
  ACanvas.Brush.Color := clWindow;
  ACanvas.Font.Color := clWindowText;
end;

In my case I am not using any theming so the colors match. If you are using something different you have to change them accordingly.