We recommend using Visual Studio 2017

XmlEvents Class

The collection of all XmlEvent events for a form template.

Namespace: Microsoft.Office.InfoPath
Assembly: Microsoft.Office.InfoPath (in microsoft.office.infopath.dll)

The XmlEvents collection and XmlEvent class are used to bind a document-level event (such as the Changed event for a field or group in a form's underlying XML document) to an event handler in the InternalStartup method at the beginning of the of the FormCode class in a managed code form template. At run time, the InternalStartup method is executed when the form template is opened to initialize the binding of all event handlers.


The InternalStartup method and the event binding code within it are generated by InfoPath when you add event handlers using various user interface commands. You should not create the InternalStartup method or write any additional code within it yourself. For information about how to add event handlers using interface commands, see How to: Add an Event Handler.

The example below shows code generated by InfoPath in the InternalStartup method to bind the event handler for a Validating event associated with a field in the form's underlying XML document using the XmlEvents.Item(String) property of the XmlEvents class. It also shows the code generated for the Changed event of a field bound to the CategoryName column of a secondary data source named Categories using the XmlEvents.Item(String,String) property of the XmlEvents class.

public void InternalStartup()
      += new XmlChangedEventHandler(field1_Validating);
      += new XmlChangedEventHandler(


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.