I have a dialog box with Yes, No and Cancel clicking Yes save the currently created project, On clicking the Cancel button should just close the Dialog box doing no action.
private void closeproject_click(DialogResult DResult)
{
if(MessageBox.Show("Do you want to save the project and close tool?
MessageBoxButtons.YesNoCancel) == DialogResult.Yes))
{
//Save the current Project if not saved and close
}
else if("Do you want to save the project and close tool?
MessageBoxButtons.YesNoCancel) == DialogResult.No))
{
//doesn't save the project and get closes
}
else if("Do you want to save the project and close tool?
MessageBoxButtons.YesNoCancel) == DialogResult.Cancel)
{
// should close the dialog box form only
// what do i write
}
Complete Tool should not get closed, only the dialog should close on clicking the Cancel Button and kill the background process.
You should use simple approach to perform what you are trying to do.