views:

507

answers:

1

I'm using a List to bind to a dataGridView. I'd like the user to be able to add a new row.

I've tried using a BindingList and a BindingSource.

Here's my binding (not including the combo box column I add to the datagridview before adding a datasource:

binding = new BindingSource();
binding.DataSource= _Rows;
_dg.DataSource = binding;

Here's the code that fills _Rows

protected override List<BusinessApp> getRows(DataGridViewManager manager)
 {
  var dc = manager.dc.DcHerb;
  return (from p in dc.apps
    where p.zQueueId == this.ZQueueId
    select p)
       .ToList().ToBusinessApp(dc);
 }

Here's what I'm trying to get a new row. No exception occurs, but the dataGridView doesn't appear to change at all, even though _Rows count goes from 68 to 69

private void newRow()
 {

  _Rows.Add(new BusinessApp(_manager.dc.DcHerb, new app() {acaps="1234"  }));

  //_dg.DataSource = binding; //tried rebinding here
  //_dg.DataSource = _Rows;
 }
A: 

I would as if you have any foreign key bind to the other table or not, if yes, you may assign a key to the new added row and the datagrid will show the current new added row. Otherwise you may also missing the code datagrid.EndEdit()