title: Handling changes in ObservableCollection
body: <p>I have little problem with handling data modifications in my datagridView.
  I bind a DataSource to the datagridview just like this:</p>
  
  <pre><code>     private void Form1_Load(object sender, EventArgs e)
      {
          var customersQuery = new ObservableCollection&lt;Payment&gt;(context.Payments);
          customersQuery.CollectionChanged += new NotifyCollectionChangedEventHandler(customerQuery_Changed);
          dataGridView1.DataSource = new BindingSource() { DataSource = customersQuery };
  
      }
      OrdersDataModelContainer context = new OrdersDataModelContainer();
  </code></pre>
  
  <p>and I'm handling changes like below:</p>
  
  <pre><code>    private void customerQuery_Changed(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
      {
          if (e.Action == NotifyCollectionChangedAction.Add)
          {
              foreach (Payment p in e.NewItems)
              {
                  context.Payments.Add(p);
              }
          }
          if (e.Action == NotifyCollectionChangedAction.Remove)
          {
              foreach (Payment p in e.OldItems)
              {
  
                  context.Payments.Remove(p);
              }
          }
          context.SaveChanges();
      }
  </code></pre>
  
  <p>Remove works but Add not so well. Add action is called when I click on the new row co I'm getting exception because cell are empty. How in simply way I can change behavior to call Add after inserting is over and i switch to next row?
  Another problem is with modifications  of existing data rows. They are updated in database only after inserting new data.</p>
  
  <p>Can anyone give me solution or point where I should search for it?</p>