I am writing a C# code for the checkbox here. I want to get the checkbox unchecked if the messsagebox replies with "No". But it still in checked status. I have tried several ways but not working yet. I think my logic is correct but the output is not. chkComplete.Checked = false;
is not working.
private void chkComplete_BeforeCheckStateChanged(object sender, System.ComponentModel.CancelEventArgs args)
{
// ** Place Event Handling Code Here **
if (!chkComplete.Checked) {
DialogResult dr = MessageBox.Show("Are you sure you want to complete this project?",
"Confirmation", MessageBoxButtons.YesNo);
switch(dr)
{
case DialogResult.Yes:
MessageBox.Show("Please make sure the project is saved!");
epiShapeC1.Enabled = true;
break;
case DialogResult.No:
MessageBox.Show("The project will stay incomplete!");
chkComplete.Checked = false;
epiShapeC1.Enabled = false;
break;
}
} else {
epiShapeC1.Enabled=false;
}
}
Aucun commentaire:
Enregistrer un commentaire