mercredi 2 janvier 2019

How to check if multiple checkbox is selected or not in datagridview c#

I have a DataGridview where i can select multiple checkbox.but now i need to collected checked rows data and keep it. how can i check how many of my rows are selected and how can i keep me selected checkbox rows data.

I already did little code. but this only keep only one selected rows data. Here is my code-

 DataGridViewCell datacelll = dgvSlsSRsList.CurrentCell;

if (datacelll != null)                            
{
     foreach (DataGridViewCheckBoxCell cell in dgvSlsSRsList.SelectedCells)
     {
          cell.Value = true;
          slssrsId = Convert.ToInt32(dgvSlsSRsList.Rows[e.RowIndex].Cells[1].Value);
          slssdpId = Convert.ToInt32(dgvSlsSRsList.Rows[e.RowIndex].Cells[2].Value);
          DueAmount = Convert.ToDecimal(dgvSlsSRsList.Rows[e.RowIndex].Cells[8].Value);
      }

      dgvSlsSRsList.Refresh();                                
}




Aucun commentaire:

Enregistrer un commentaire