Clear selected data from the datagridview

0

Hello, what I want to do is delete the selected data in the datagriedview what I have from my code button "Remove" (gives me erores) in the line foreach(DataGridViewRow c in DataGridViewSelectionArea.Rows) :

    private void BtnQuitar_Click(object sender, EventArgs e)
  {
      foreach(DataGridViewRow item in DataGridViewSelectionArea.SelectedRows)
      {
          DataGridViewSelectionArea.RemoveAt(item.Index);

      }

    }

    
asked by Alejandro Estupiñán 26.12.2018 в 22:28
source

1 answer

0

Hi, I think you can use the direct remove method

        foreach (DataGridViewRow item in dgRoot.SelectedRows)
        {
            dgRoot.Rows.Remove(item);
        }

        dgRoot.Refresh();
    
answered by 27.12.2018 в 01:17