Please enable JavaScript to view this site.

Altova XMLSpy 2020 Enterprise Edition

The code snippet below (from the AutomateXMLSpy example) lists the code for two event handlers. The AutomateXMLSpy example (see the file Form1.cs)  is located in the C# folder of the API Examples folder:

 

Windows 7, Windows 8, Windows 10

C:\Users\<username>\Documents\
Altova\XMLSpy2020\

 

You can compile and run the project from within Visual Studio 2010/2012/2013/2015/2017/2019.

 

 

      // Event handler for OnDocumentOpened event

      private void handleOnDocumentOpened(XMLSpyLib.Document i_ipDocument)

       {

          MessageBox.Show("Document " + i_ipDocument.Name + " was opened!");

       }

 

      // Remember if the event handler is currently registered.

      private bool bEventHandlerIsRegistered = false;

 

      // Handler for button 'OnDocuemntOpened Event On/Off

      private void toggleOnDocumentOpenedEvent_Click(object sender, EventArgs e)

       {

          if (XMLSpy != null)

           {

              if (bEventHandlerIsRegistered)

                   XMLSpy.OnDocumentOpened -= new XMLSpyLib._IApplicationEvents_OnDocumentOpenedEventHandler(handleOnDocumentOpened);

              else

                   XMLSpy.OnDocumentOpened += new XMLSpyLib._IApplicationEvents_OnDocumentOpenedEventHandler(handleOnDocumentOpened);

 

               bEventHandlerIsRegistered = !bEventHandlerIsRegistered;

           }

       }

 

© 2019 Altova GmbH