I am using c# WinForms. I have a save dialog box that pops up and a message box after that that says it was saved successfully.
I just realized that if a user clicks cancel, my message box still comes.
How do i tell when a user clicks the cancel button on a save dialog box and then do something when it is cancelled?
Use DialogResult
if (form.ShowDialog() == DialogResult.Cancel)
{
//user cancelled out
}
For SaveFileDialog
:
SaveFileDialog saveFileDialog = new SaveFileDialog();
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
MessageBox.Show("your Message");
}