toanhoi bui

toanhoi bui

  • NA
  • 70
  • 207.1k

Using Event Checkbox in Datagridview

May 13 2011 4:03 AM
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)