1

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?

Skrymsli
  • 5,173
  • 7
  • 34
  • 36
  • I'm not sure if the lost focus thingy will work. I've tried that once and the lost focus event is not fired in the scenario. No idea why exactly. – Dig Sep 18 '11 at 10:12

1 Answers1

0

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.

Udo
  • 449
  • 3
  • 13