Re: NSTableView setUsesAlternatingBackgroundColors:TRUE not working for added columns?
Re: NSTableView setUsesAlternatingBackgroundColors:TRUE not working for added columns?
- Subject: Re: NSTableView setUsesAlternatingBackgroundColors:TRUE not working for added columns?
- From: Jim Hagen <email@hidden>
- Date: Fri, 19 Mar 2004 10:23:59 -0800
Honestly, I did try to search the archives for this before asking...
and I can also understand why it'd be problematic at best for the
NSTableView to automatically tell all of it's cells not to draw their
backgrounds. I was actually thinking I'd file a bug report against the
documentation- if the API documentation for
setUsesAlternatingBackgroundColors mentioned a few more details about
how it works, I'd know that table column text fields are supposed to
have setDrawsBackground:NO for the color to show through. As it'd
documented, you don't know how the alternating colors are done and so
can't infer behavior under different situations.
So, it's a well-known bug. I suppose I should take the time to file a
bug report anyway...
Thanks for the answer...
-jim
On Mar 18, 2004, at 4:38 PM, Jonathan Jackel wrote:
This has been covered many times in the archives. It's a bug. You
need to do this:
[[cColumn dataCell] setDrawsBackground:NO];
I would do it just before you add the column to the table view.
Jonathan
On Mar 18, 2004, at 2:00 PM, Jim Hagen wrote:
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.