Events Imprimer cette rubrique Page précédente Un niveau supérieur Page suivante

Accueil >  Programmers' Reference > Application API > Overview > Programming Languages > C# >


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 2008 or Visual Studio 2010.



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




© 2018 Altova GmbH