tags:

views:

83

answers:

2

Is there a way in C# winform to alter the cancel button event of open or save dialog box.

+1  A: 

Look into DialogResult and you'll find what you're looking for.

Dialog dialog = new <file save dialog>();

if (dialog.ShowDialog() == DialogResult.Cancel)
{
//   your code here
}

DialogResult in Google

Peter
+2  A: 

It depends on what you mean by alter. You cannot edit the behavior of the ShowDialog, you can only handle the result returned and take the appropriate action. OpenFileDialog is a sealed class, which means you cannot inherit from it and override behavior. If you truly need control at when the OpenFileDialog is shown, you'll need to create your own form to handle the necessary behavior.

Timothy Carter