title: Deleting From DGV -- Index [x] does not have a value
body: <p><strong>The Setup:</strong>
  I have a two DataGridViews, each bound to a BindingList&lt;> of custom business objects.  These grids have a special row containing the mathematical totals of all rows in that grid -- this special row is reflective of a corresponding special object in the BindingList&lt;> (I specify that so that you are aware that this is not a row being added to the DGV, but an object being added to the BindingList&lt;>).  </p>
  
  <p><strong>The Error:</strong>
  There comes a time, periodically, where I must find and remove the Totals Row object from the BindingList&lt;> (and thus from the DGV).  Here is the original code I was using to do this:</p>
  
  <pre><code>private void RemoveTotalRow()
    {
       for (int i = UnderlyingGridList.Count - 1; i &gt;= 0; i--)
       {
          if (UnderlyingGridList[i].IsTotalRow) UnderlyingGridList.RemoveAt(i);  
       }
    }
  </code></pre>
  
  <p>(It's not super-important, but the reason I'm cycling through all records is to protect against the possibility that there could be more than one Totals row, by mistake).  This code <strong>works flawlessly</strong> for one of the two grids under all circumstances.  However, on the second grid I get the following error when the RemoveAt method is called:</p>
  
  <pre><code>The following exception occurred in the DataGridView:  System.IndexOutOfRangeException: Index 5 does not have a value.    at System.Windows.Forms.CurrencyManager.get_Item(Int32 index)    at System.Windows.Forms.DataGridView.DataGridViewDataConnection.GetError(Int32 rowIndex)  To replace this default dialog please handle the DataError event.
  </code></pre>
  
  <p>...where '5' is the index of the totals row.  <a href="https://stackoverflow.com/questions/890950/datagridview-on-winforms-throws-exception-when-i-delete-a-record">I found this question</a>, which is essentially the same, except that the accepted answer is to either:  1) Not use an underlying list, which I must do, or 2) Delete from the grid instead of from the list.  I have tried #2 by replacing the innermost method call from my code example above with this:</p>
  
  <pre><code>if (UnderlyingGridList[i].IsTotalRow) brokenDataGrid.Rows.RemoveAt(i);
  </code></pre>
  
  <p>This throws the same error.  <a href="https://stackoverflow.com/questions/1630200/net-datagridview-index-0-does-not-have-a-value">I also found this question</a>, which suggests rebinding after the change - however, this is not feasible as it is possible for this code to be called once per second and if the list is too heavily populated it will make the grid unusable (I know this from bad experiences).</p>
  
  <p>I could just handle the grid's DataError event, but I'd rather not have the thing popping a million errors per minute, even if they are silent.  Any help would be greatly appreciated.</p>