title: DataGridView Removed rows cells still show up in code, even though removed from Grid
body: <p>So in my code, I have a delete button then when clicked will remove the selected rows from the Grid. </p>
  
  <p>This appears to work at the UI level.</p>
  
  <p>But when I had to rederive my data from the cells in the Grid, somehow the stuff I just deleted was still in there. I learned this as I was looping through line by line in debug mode.</p>
  
  <p>My Base algorithm came from <a href="https://stackoverflow.com/questions/2084346/delete-selected-row-from-datagridview-and-update-db">this stackoverflow post</a>'s first answer. 
  Now I looked at the MSDN <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewrowcollection.removeat(v=vs.110).aspx" rel="nofollow noreferrer">here</a> about what RemoveAt actually does
  Unfortunately, it wasn't very enlightening.</p>
  
  <pre><code> Removes the row at the specified position from the collection.
  </code></pre>
  
  <p>Here is my code.</p>
  
  <pre><code>private void Delete_Click(object sender, EventArgs e)
      {  
  
          if (this.DataView.SelectedRows.Count &gt; 0)
          {
              foreach (DataGridViewRow item in DataView.SelectedRows)
              {
                  DataView.Rows.RemoveAt(item.Index);
  
              }
  
          }
  
          refreshDataFromGrid();
      }
  </code></pre>
  
  <p>Now here is the part that derives the Data from what is in the Grid</p>
  
  <pre><code>    private void refreshDataFromGrid()
      {
          //if the rows in the gridview aren't empty copy them over to the String array in d.value
          for (int i = 0; i &lt; DataView.Rows.Count; i++)
          {
              for (int j = 0; j &lt; DataView.Rows[i].Cells.Count; j++)
              {
                  if (DataView.Rows[i].Cells[j].ToString() != "")
                  {
                      (DataViewParent as STS_Console.MenuItems.MenuItem).d.Value[i, j] = DataView.Rows[i].Cells[j].Value.ToString();
  
                  }
              }                                                                                                       
  
          }
  
      }
  </code></pre>
  
  <p>I would be glad to provide screenshots or anything else as necessary, just ask. </p>