4
Answers

Using Event Checkbox in Datagridview

toanhoi bui

toanhoi bui

13y
2.6k
1
Hi eveybody, I want to throw event checkbox in Datagridview is checked
Code my Here:
public int  chon = 0;
  private void dgvNvHop_CellContentClick(object sender, DataGridViewCellEventArgs e)
  {
  try
  {
  if (chon == 0)
  {
  chon = 1;
  dgvNvHop.Rows[e.RowIndex].Cells["Chon"].Value = true;
  }
  else
  {
  chon = 0;
  dgvNvHop.Rows[e.RowIndex].Cells["Chon"].Value = false;
  }
  }
  catch { }
  }
 
But When I click into a checkbox  ,it set true.and after if  I remove click it,it set false.But I get all checkbox is values equal true .Checkbox is remove click still values true.I don't understand
Answers (4)