I have a table with two checkBoxes and I want to uncheck one of it while the other one is checked (like RadioButton).
void DataGridView1CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
try{
DataGridViewCheckBoxCell never = dataGridView1.Rows[e.RowIndex].Cells[1] as DataGridViewCheckBoxCell;
DataGridViewCheckBoxCell once = dataGridView1.Rows[e.RowIndex].Cells[2] as DataGridViewCheckBoxCell;
bool isNeverChecked = (bool)never.EditedFormattedValue;
if(isNeverChecked){
once.Value = "false";
never.Value = "true";
}else{
once.Value = "true";
never.Value = "false";
}
dataGridView1.Refresh();
}catch{};
}
Aucun commentaire:
Enregistrer un commentaire