I was using a MessageBox to show a confirmation message when the user goes to delete an item and initially used MessageBoxButtons.YesNoCancel. Later I changed it to YesNo instead because a user pointed out that there was no real difference in “No” and “Cancel” in this case. My question is…what is the difference? Is there ever a reason to use YesNoCancel instead of YesNo?
Share
Sure there could be. For example, if there is a save dialog and you enter a filename that already exists, the dialog could ask you if you want to overwrite the file.
Yes would mean overwrite the file. No might mean append a “(1)” at the end of the file name, or prompt for a different file name. Cancel might mean don’t save after-all.
You should note that
Yes,No, andCancelare all different enums and do not have the same value, so you can treat them differently.REMEMBER TO HANDLE CANCEL ANYWAY because if the user clicks the
xbutton in the top right corner of your dialog screen, the result ofShowDialog()isDialogResult.Cancel!