Edit

Share via


XmlEvents Class

Definition

The collection of all XmlEvent events for a form template.

public ref class XmlEvents abstract
public abstract class XmlEvents
type XmlEvents = class
Public MustInherit Class XmlEvents
Inheritance
XmlEvents

Examples

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 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 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);
}
Private Sub InternalStartup(ByVal sender As Object, _
   ByVal e As EventArgs) Handles Me.Startup
   AddHandler EventManager.XmlEvents( _
      "/my:myFields/my:field1").Validating, _
      AddressOf field2_Validating
   AddHandler EventManager.XmlEvents( _
      "/dfs:myFields/dfs:dataFields/d:Categories/@CategoryName", _
      "Categories").Changed, _
      AddressOf Categories__CategoryName_attr_Changed
End Sub

Remarks

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: 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.

Constructors

XmlEvents()

Properties

Item[String, String]

Gets an XmlEvent from the XmlEvents collection for binding an event handler by specifying the XPath of the underlying XML document node that can raise the event and the name of the secondary data source that supplies the data.

Item[String]

Gets an XmlEvent from the XmlEvents collection for binding an event handler by specifying the XPath of the underlying XML document node that can raise the event.

Applies to