This happens because DataGridView
allows to remove rows only when it is bond to IBindingList
implementation (see note below), and IBindingList.AllowRemove
returns true.
You can wrap your list into BindingList<T>
, which allows to remove items by default:
dataGridView1.DataSource = new BindingList<Customer>(dc.Customers.ToList());
Note. Data.CustomersDataContext.Customers
implements IListSource
, which returns IBindingList
with AllowRemove == true
, that's why your first case works, as expected. DGV
knows about IListSource
and uses IListSource.GetList()
result as the data source.