Activer JavaScript pour consulter ce site.

Altova XMLSpy 2021 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



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


Code snippet


       // 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);


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


               bEventHandlerIsRegistered = !bEventHandlerIsRegistered;




© 2015-2021 Altova GmbH