crystalNet
crystalNet

Reputation:

Is there a way to get hold of the cancel event of the dialog boxes

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

Upvotes: 2

Views: 314

Answers (2)

Timothy Carter
Timothy Carter

Reputation: 15785

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.

Upvotes: 2

Peter
Peter

Reputation: 1806

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

Upvotes: 1

Related Questions