Forums - C# Corner

Forum guidelines
Richard Arnold

Richard Arnold

  • 1.3k
  • 10
  • 14.2k

Responding to DialogResult RetryCancel

Jan 1 2013 8:52 PM
My application allows the user to select a particular file to import from a ToolStripDropDownButton. The code then displays an OpenFileDialog for them to browse to the file to import.
As the file actually chosen may be different from the selected ToolStripDropDownButton item, I want to  prevent an incorrect file from being copied. I wrote a method which compares the two selections and displays a RetryCancel DialogResult in a MessageBox.

If the user clicks "Retry", I want to return to the calling code's OpenFileDialog for the user to make another file selection.

If the user clicks "Cancel", I do Not want to exit the application, just allow the user to continue using the application.

How do I return to the calling code's OpenFileDialog based on the "Retry" button and how can I handle the "Cancel" button?

I have attached the simple method example. Thank you in advance.

Answers (2)

techbash 2016

SPONSORED BY

File APIs for .NET
Aspose are the market leader of .NET APIs for file business formats – natively work with DOCX, XLSX, PPT, PDF, MSG, MPP, images formats and many more!