0

I have a Datagridview in which i am adding a DatagridviewCheckbox column. The problem i am facing is when i run my program and then try to check my checkbox, it doesn't get checked. Even i have set datagridview's Editing as enabled and despite trying every other solution on the internet and here at stackoverflow, only this thing code worked for me but using this code, i could be able to check it only:

private void data_grid1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
      data_grid1.BeginEdit(true);
      data_grid1.Rows[e.RowIndex].Cells["Select"].Value = true;
}

But this is just letting me check it for once only and then when i click again so it doesn't get unchecked. Please help me as what should i be doing?

Sameer
  • 71
  • 1
  • 1
  • 8

1 Answers1

0

Finally i got my answer by myself. Here is the solution!

                data_grid1.Rows[e.RowIndex].Cells["Select"].Value = true;
                if(!data_grid1.CurrentCell.Value.ToString().Equals(true))
                {
                    data_grid1.Rows[e.RowIndex].Cells["Select"].Value = true;
                }
                else if(data_grid1.CurrentCell.Value.ToString().Equals(true))
                {
                    data_grid1.Rows[e.RowIndex].Cells["Select"].Value = false;
                }
Sameer
  • 71
  • 1
  • 1
  • 8