• 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
Re: NSTableView -- add rows on button click
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTableView -- add rows on button click


  • Subject: Re: NSTableView -- add rows on button click
  • From: Fritz Anderson <email@hidden>
  • Date: Mon, 4 Jun 2001 22:44:32 -0500

At 3:58 PM -0700 6/4/2001, email@hidden wrote:
I have a form set up with text fields and a button, with a NSTableView. What I want to happen is that when the button is clicked, the TableView adds a row and fills in the data. I can get the values into the table, but I don't know how to have the table add a row. How can i force the TableView to call the - (int)numberOfRowsInTableView:(NSTableView *)tableView function???

Here is IBAction code that worked for me. It belongs to the controller object. It has members:

model -- has an NSMutableArray that allocates and manages a list of "component" instances.

deleteButton -- an NSButton the action of which is to delete the selected line of the table; it ought to be disabled if there is no selected line.

partTable -- the TableView for which the controller is delegate and data source. The short answer to your question is the message [partTable reloadData].

-- F


- (IBAction) addPartFrom: (id) source
{
int row;

if (!model)
return;

// Add an untitled part to the list

row = [partTable selectedRow];
if (row < 0) {
// No selection: append
[model addComponent];
row = [model countComponents] - 1;
}
else {
// Selection: insert.
[model insertComponentBeforeIndex: row];
}

// Tell the table we've changed
[deleteButton setEnabled: YES];
[partTable reloadData];

// Select the new row.
[partTable selectRow: row
byExtendingSelection: NO];
}


References: 
 >NSTableView -- add rows on button click (From: email@hidden)

  • Prev by Date: Re: NSOutlineView and background color
  • Next by Date: Threads in Apps
  • Previous by thread: NSTableView -- add rows on button click
  • Next by thread: Newbie window controller question
  • Index(es):
    • Date
    • Thread