I need to execute code when a checkbox on a datagrid is check/unchecked, theres not much else to say.
I have searched, and found people suggesting it can be done based on the CellContentClick event. Even though multiple people suggest this and it is said to work, for me it doesn't as clicking the checkbox doesn't count as the content being clicked. The code I have implemented for this is:
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (Convert.ToBoolean(dataGridView1.Rows[e.RowIndex].Cells[CC.Name].Value) == true)
{
txtCCs.Text += dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString().Trim() + ", ";
}
}
This does not run when the checkbox is ticked/unticked though, it does run however if I then click on another cell for the row of the checked checkbox. Proving, for me atleast, the CellContentClick doesn't apply to the datagrid checkbox change state.
Aucun commentaire:
Enregistrer un commentaire