Deleting from subsonic collection associated with winforms datagridview

I have a winforms application that I added a DataGridView bound to a subsonic collection via a BindingSource for it.

The grid works fine for adding / editing (other than displaying the ComboBox column ), but I can't seem to get it to remove rows from the database correctly.

If I remove a row from the DataGridView, I cannot tell if the collection is dirty and when I call. The BatchSave method of subsonic dialing removes all rows.

0


a source to share


2 answers


In 2.2, SaveAll should also remove items removed from your datagridview document.

In 2.1 you have to make a call



ItemCollection.ProcessDeletedItems()

      

too

+1


a source


Just do the following:



private void productBindingSource_ListChanged(object sender, ListChangedEventArgs e)
{
    ((ProductCollection)productBindingSource.List).SaveAll();
}

      

+1


a source







All Articles