Export (0) Print
Expand All

XmlEvents Class

Office 2010

The collection of all XmlEvent events for a form template.

System.Object
  Microsoft.Office.InfoPath.XmlEvents

Namespace:  Microsoft.Office.InfoPath
Assembly:  Microsoft.Office.InfoPath (in Microsoft.Office.InfoPath.dll)

public abstract class XmlEvents

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.

Important noteImportant

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()
{
   EventManager.XmlEvents["/my:myFields/my:field1"].Validating 
      += new XmlChangedEventHandler(field1_Validating);
   EventManager.XmlEvents[
      "/dfs:myFields/dfs:dataFields/d:Categories/@CategoryName", 
      "Categories"].Changed 
      += new XmlChangedEventHandler(
      Categories__CategoryName_attr_Changed);
}

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