public static void RemoveAll(this DataGridViewRowCollection collection, Func <DataGridViewRow, bool> predicate) { if (collection == null) { throw new ArgumentNullException(nameof(collection)); } if (predicate == null) { throw new ArgumentNullException(nameof(predicate)); } collection.RemoveAll(collection.Cast <DataGridViewRow>().Where(predicate)); }