NSTableView column background

Is there a method to change the background color of a specific column in a cell-based table?
I would like to “highlight” a column after I made a search on the table’s data.

I saw there’s a setHighlightedTableColumn: method for NSTableView class but can’t figure out how to pass the column parameter.

Otherwise, is it possible to use setBackgroundColor on a specific column at runtime?

You could use tableColumnWithIdentifier: or tableColumns()'s objectAtIndex:.

Hi Shane!

That’s what I was using:
'(theTable’s setHighlightedTableColumn:(theTable’s tableColumns()‘s objectAtIndex:4))’
It’s not working here.

Do I have to set some table property before?

I suspect you’re expecting to see more than it delivers. I think it just sets the sorted column.

Yes. You’re right!
The word highlighted in the method name is confusing for me.

Anyway, I found another way to achieve what I want:
I’m moving a 2 pixels high red box above the bottom of the header, setting its left and width according to the column I want to highlight.

capture 003

I wonder if the option Table View > Selection > Column in Interface Builder can be helpful? It will highlight the entire sort column - but I’m not sure if that’s what you need.
Untitled 10

Hi Leo,

Selecting this option make it possible not only to highlight the Column but also to change its background.
The problem, in my case, is that I don’t want the columns to be selectable.
And finally, I find the red box solution much more elegant.

Thank you anyway for your participation.