Re: Please help! Dynamically changing the NSTableView header ?
Re: Please help! Dynamically changing the NSTableView header ?
- Subject: Re: Please help! Dynamically changing the NSTableView header ?
- From: "chris corbell"<email@hidden>
- Date: Fri, 13 Sep 2002 15:33:26 -0700
Philipp Seibel wrote:
>
Hi everybody,
>
>
i'd like to load a csv file into a NSTableView, >but i couldn't fill the
tableheader with the >strings in the first line of the csv file.
>
Does anybody know how to get along with this.
>
>
thx
>
>
Phil
I believe you just need to get the column
whose header you wish to change and set the
title of its header cell. This worked for
me - the code below is for adding a new column
but it should also work if you just get the
existing NSColumn. This is an instance method
of a data source class; m_records is an
NSArray.
Hope this helps,
Chris
- (void)AddColumn:(NSString *)sColumnIdentifier values:(NSArray *)valueArray
withTitle:(NSString *)sColumnTitle
{
NSTableColumn * pColumn = nil;
int nIndex, nCount;
nCount = [valueArray count];
NSParameterAssert(nCount == [m_records count]);
if(nCount > [m_records count])
nCount = [m_records count];
for(nIndex = 0; nIndex < nCount; nIndex++)
{
[self SetValueForRecord:[self GetRecordForIndex:nIndex]
withKey:sColumnIdentifier value:[valueArray objectAtIndex:nIndex]];
}
pColumn = [[NSTableColumn alloc] initWithIdentifier:sColumnIdentifier];
[[pColumn headerCell] setStringValue:sColumnTitle];
[m_tableView addTableColumn:pColumn];
}
_______________________________________________
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.