EventManager Class
Used to initialize and bind event handlers in the InternalStartup method of a form template.
Inheritance Hierarchy
System.Object
Microsoft.Office.InfoPath.EventManager
Namespace: Microsoft.Office.InfoPath
Assembly: Microsoft.Office.InfoPath (in Microsoft.Office.InfoPath.dll)
Syntax
'Declaration
Public MustInherit Class EventManager
'Usage
Dim instance As EventManager
public abstract class EventManager
Remarks
The EventManager class is used by InfoPath to bind event handlers for all of the events implemented by the ControlEvents, FormEvents, and XmlEvents classes in the InternalStartup method at the beginning 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.
Note
When a form template is opened in InfoPath, the InternalStartup method is called whenever a user opens the form template. Whereas, when a form template is opened in a Web browser from an appropriately configured document library on SharePoint Server 2010 running InfoPath Forms Services, the InternalStartup method is called only the first time the form template business logic assembly is loaded into an AppDomain on the server. This usually corresponds to the time the first user opens an instance of the form template during a session, or after the AppDomain is recycled during a session.
Examples
The following examples, show the InternalStartup method from a FormCode class (from the FormCode.cs or FormCode.vb files) of a form template that binds the event handlers for a form's Loading event, a field's Changed event, and a Button control's Clicked event using their corresponding delegates.
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.
public void InternalStartup()
{
EventManager.FormEvents.Loading +=
new LoadingEventHandler(FormEvents_Loading);
EventManager.XmlEvents["/my:myFields/my:Name"].Changed +=
new XmlChangedEventHandler(Name_Changed);
((ButtonEvent)EventManager.ControlEvents["MyBtn"]).Clicked +=
new ClickedEventHandler(MyBtn_Clicked);
}
Private Sub InternalStartup(ByVal sender As Object, _
ByVal e As EventArgs) Handles Me.Startup
AddHandler EventManager.FormEvents.Loading, _
AddressOf FormEvents_Loading
AddHandler EventManager.XmlEvents("/my:myFields/my:Name").Changed, _
AddressOf Name_Changed
AddHandler DirectCast(EventManager.ControlEvents("MyBtn"), _
ButtonEvent).Clicked, AddressOf MyBtn_Clicked
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.