title: Deleting multiple rows in an unbound datagridview
body: <p>I have a project that reads rows from an SQL database and displays them in a datagridview. That part works great. I want to show a subset of these records by deleting every non selected row in the grid. This is the code:</p>
  
  <pre><code>foreach (DataGridViewRow row in dataGridView1.Rows)
  {
      if (!row.Selected)
      {
           if (!row.IsNewRow)
           {
                dataGridView1.Rows.Remove(row);
              //dataGridView1.Rows.Remove(dataGridView1.CurrentRow);
           }
       }    
  }
  </code></pre>
  
  <p>It either deletes from the bottom up to the selected area and leaves the unselected rows above, or deletes selected as well as unselected rows.</p>
  
  <p>Could anyone point me in the right direction?</p>