EventManager Class (Microsoft.Office.InfoPath)
Assembly: Microsoft.Office.InfoPath (in microsoft.office.infopath.dll)
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.
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 Microsoft Office Forms Server 2007 or from an appropriately configured document library on Office SharePoint Server 2007 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.
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.
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.
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