Edit

Share via


EventManager Class

Definition

Used to initialize and bind event handlers in the InternalStartup method of a form template.

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

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

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.

Constructors

EventManager()

Properties

ControlEvents

Gets a ControlEvents object for binding an event handler in the InternalStartup method of a form template.

FormEvents

Gets a FormEvents object for binding an event handler in the InternalStartup method of a form template.

XmlEvents

Gets a XmlEvents object for binding an event handler in the InternalStartup method of a form template.

Applies to