Not able to add columns to a NSTable
Not able to add columns to a NSTable
- Subject: Not able to add columns to a NSTable
- From: "Amit Sadana" <email@hidden>
- Date: Tue, 27 Jan 2004 12:02:17 +0530
- Thread-topic: Not able to add columns to a NSTable
I have a custom view myView to which I am trying to add newly created
table. I am able to create the a faint table border and it displays in
the view but as soon as I add a column to it, the table disappears. I
noted that its frame rect values were somehow getting changed. But even
after resetting the rect values, only a faint table outline is shown but
no columns or column header
My intent is to show only the column headers and the table border, not
any data as of now, that is why I am not setting any data source and
delegate.
Here is the code
-(void) awakeFromNib
{
NSRect myRect;
//Setting the following values appropriately
myRect.origin.x =
myRect.origin.y =
myRect.size.width =
myRect.size.height =
NSString *name1 = @"Col1";
NSString *name2 = @"Col2";
NSTableView *myTableView = [[NSTableView alloc] init];
[myTableView initWithFrame:myRect];
NSTableColumn *tc1 = [[NSTableColumn alloc]
initWithIdentifier:name1];
NSTableColumn *tc2 = [[NSTableColumn alloc]
initWithIdentifier:name2];
[myTableView setAllowsColumnSelection:YES];
[myTableView setDrawsGrid:YES];
[[tc1 headerCell] setStringValue:name];
[[tc1 headerCell] setBordered:YES];
[[tc1 headerCell] setEnabled:YES];
[tc1 setResizable:YES];
[[tc2 headerCell] setStringValue:name];
[[tc2 headerCell] setBordered:YES];
[[tc2 headerCell] setEnabled:YES];
[tc2 setResizable:YES];
[myTableView addTableColumn:tc1];
[myTableView addTableColumn:tc2];
//Ideally following shouldn't be needed. But the frame size
//somehow gets changed after adding a column
NSRect resetRect = myRect;
[myTableView setFrame:resetRect];
[mvView addSubview:myTableView];
}
Thanks.
-Amit
_______________________________________________
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.