I am trying to create an if statement to prompt me asking if i am sure i want to check the checkbox. If the checkbox is already checked to just uncheck the box. Below is what i have an cant seem to get to work. Thanks! if anyone has a simple way of doing this please advise.
if (checkBox15.Checked == false)
{
MessageBox.Show("Are you sure you want to check this?", "Prompt", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
Updatelist();
}
else
{
checkBox15.Checked = false;
return;
}
}
else if (checkBox15.Checked == true)
{
checkBox15.Checked = false;
return;
}
You have missed if(
if(MessageBox.Show("Are you sure you want to check this?",
"Prompt",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question) == DialogResult.Yes)
{
Updatelist();
}
else
{
checkBox15.Checked = false;
return;
}
This Is Your Answer
if (checkBox15.IsEnabled == false)
{
MessageBox.Show("Are you sure you want to check this?", "Prompt", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
Updatelist();
}
else
{
checkBox15.IsEnabled = false;
return;
}
}`enter code here`
else if (checkBox15.IsEnabled == true)
{
checkBox15.Checked = false;
return;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.