Edit AllPages

I am trying to make certain rows in NSTableView to be disabled. I have tried to use setEnabled method, which didn’t work for me. Can someone help me to solve this problem? Thanks

What do you mean disabled? Do you have a text cell that you don’t want to be editable or do you have controls embedded in the rows you want disabled? Check out the delegate methods in the documentation for NSTableView - (BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex is what you’re most likely looking for.

// This belongs in your tableview’s delegate. It looks for the cell at disabledRow and textColumn (made up - // assume these are valid. You’re free to determine whether the cell should be editable any way you like, though.

And if you want a text cell to appear disabled..

By disabled, I mean that I want to display the text cell in gray, but I don’t want it to have any response to the mouse, such as edit, selet or drag. I think this will help, thanks a lot.

In that case, you will want to tell the cell itself [aCell setEnabled:NO];. One approach is to adapt the second example above. I use that method for exactly this, though there are probably better ways to do it.

In the case of the text cell, setEnabled:NO and setEditable:NO are used. This will give the appropriate effect.

No, it won’t produce the appropriate effect. setEnabled:NO fails to draw in the disabledControlTextColor but disallows editing like it’s supposed to (meaning it acts the same as setEditable:NO) when the text cell is in an NSTableView. Also, you don’t call setEnabled:NO followed by setEditable:NO because a disabled cell can’t be edited anyway.