I would like to create a MessageBox
that has Yes/No buttons AND a checkbox.
The application is a picture resizer and it will be re-sizing a number of pictures at once; in the process it will check if the new location filename exists with the option to overwrite it.
The MessageBox
will give the user the option to overwrite any new files if desired, while the checkbox will prevent having to click Yes x number of times if they want to overwrite every file.
How do I add a checkbox to a MessageBox
dialog?
You can't add a checkbox to a MessageBox. As Tim and rsbarro suggest, you should create a custom dialog. Tim's answer will work well, and doesn't require creation of a new class. If you want to design the form in the designer though, you could try this.
DialogResult
property of the Yes button to Yes, and that of the No button to No. This'll let you discover what button the user clicked.public bool DoForAll
{
get { return checkBox.Checked; }
}
var options = new Options();
var result = options.ShowDialog();
if (result == DialogResult.Yes)
{
var doForAll = options.DoForAll;
}