Forum Navigation
You need to log in to create posts and topics.

TableView: changing text color in a specific cell ( i.e. specific row/column )

Posted by: fblistserve <fblistserve@...>

On Sep 22, 2012, at 5:21 PM, Brian S <fblistserve@cox.net> wrote:


My initial research indicates:


(void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCellforTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
My initial pass at this delegate method proves it accomplishes the objective of coloring text ( code needs refinement ----a test only ).
- (void)     tableView:(NSTableView *)aTableView
       willDisplayCell:(id)aCell
        forTableColumn:(NSTableColumn *)aTableColumn
                   row:(NSInteger)rowIndex
{
    if ( aTableView == tableViewTab2 )
    {
        id keyName = [aTableColumn identifier];
        if ( [keyName isEqualToString:ColNextDateIdTab2] && (rowIndex == 0 ) ) // color next date column for row 0 only.
        {
            [aCell setTextColor: [NSColor redColor]];
        }
        else
        {
            [aCell setTextColor: [NSColor blackColor]];
        }
    }
}

Brian S.


To unsubscribe, e-mail: fbcocoa-unsubscribe@welovegod.org For additional commands, e-mail: fbcocoa-help@freegroups.net