Remove all selected rows from an editable DataGridView.
There is small catch here. The new row is also selected but will trigger an exception when removed.
The following code will work correctly.
foreach (DataGridViewRow dr in list.SelectedRows) { if (!dr.IsNewRow) { list.Rows.Remove(dr); } }