How to detect when a user navigates away from MMC FormView?

178 Views Asked by At

I have an MMC snapin (MMC 3.0) with a ScopeNode that adds a Microsoft.ManagementConsole.FormView. This FormView is used to edit a script. If the script contains syntax errors I need to prevent the user from navigating away from the form until the syntax errors are corrected. I can probably add event handlers to my script editor control to detect lost focus or window visibility change, but is there something in MMC that notifies and allows for cancelling the action?

What's the best way to detect that the user is navigating away from the FormView?

1

There are 1 best solutions below

0
On

You can detect that the user is navigating away from the FormView by overriding the OnHide method:

    protected override void OnHide()
    {
        System.Diagnostics.Debug.WriteLine("Navigated away from FormView.");
    }

Unfortunately, you cannot cancel the navigation.