• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSTableView setUsesAlternatingBackgroundColors:TRUE not working for added columns?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTableView setUsesAlternatingBackgroundColors:TRUE not working for added columns?


  • Subject: NSTableView setUsesAlternatingBackgroundColors:TRUE not working for added columns?
  • From: Jim Hagen <email@hidden>
  • Date: Thu, 18 Mar 2004 11:00:28 -0800

I have a bit of code which manipulates a table, as I don't know how many columns are in the data until runtime. I start with the minimum number ( defined in IB ) and add others.

It goes something like this :
---snippet begin----
/*create the columns*/
for ( i=[[table tableColumns] count]; i<=totalColumns; i++ ){
currentNumber = [NSNumber numberWithInt:i];

NSTableColumn *cColumn = [[NSTableColumn alloc] initWithIdentifier:currentNumber];
[[cColumn headerCell] setStringValue:[title stringByAppendingString:[currentNumber stringValue]]];
[cColumn sizeToFit];

[table addTableColumn:[cColumn autorelease]];
}

/* it appears our new columns don't know about alternating colors? can we fix that?*/
[table setUsesAlternatingRowBackgroundColors: TRUE];
/* reload the tale data */
[table reloadData];
---snippet end---

The problem is, in my newly added columns, the alternating background colors don't show up. Previously existing rows ( set up in IB) keep their alternating colors, it's just the new ones that don't have the stripes. My table had ( in IB ) been set up with usesAlternatingRowBackgroundColors TRUE, so really that line shouldn't be needed at all... but my new rows don't get the alternating color regardless, the behavior is exactly the same if that line is there or not.

Interestingly, if I say [table setUsesAlternatingRowBackgroundColors: FALSE]; instead of "TRUE", *all* rows show the non-alternating background, including the previously existing ones. I just can't get the added ones to show the alternating colors.

This is the first time I've tried adding columns to a table- is there some detail that I'm missing when doing so? Might there be some call I can make to get my new columns to show the alternating background?

Thanks in advance,
Jim
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Prev by Date: Re: Calling original functions from overriding Category functions
  • Next by Date: NSView -addSubview tutorial or example?
  • Previous by thread: Re: Calling original functions from overriding Category functions
  • Next by thread: Re: NSTableView setUsesAlternatingBackgroundColors:TRUE not working for added columns?
  • Index(es):
    • Date
    • Thread