XmlEvents Class
The collection of all XmlEvent events for a form template.
Inheritance Hierarchy
System.Object
Microsoft.Office.InfoPath.XmlEvents
Namespace: Microsoft.Office.InfoPath
Assembly: Microsoft.Office.InfoPath (in Microsoft.Office.InfoPath.dll)
Syntax
'Declaration
Public MustInherit Class XmlEvents
'Usage
Dim instance As XmlEvents
public abstract class XmlEvents
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.
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 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);
}
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
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.