C# - how do I refresh DataGridView after removing rows

Don't you need to rebind the data grid?

dgrv.Datasource = [whatever data source];
dgrv.DataBind();

?


Sometimes refreshing the data gridview is not enough and its containing parent should be refreshed too.

Try this:

dgv.Refresh(); // Make sure this comes first
dgv.Parent.Refresh(); // Make sure this comes second

You could also edit your source and attach the new datasource to the control.


If you have bound your datagrid to an Observable Collection (if not then you should) then you will need to implement INotifyCollectionChanged interface so that listeners are notified of dynamic changes, such as when items get added and removed or the whole list is refreshed.

HTH