_XDocumentEventSink2_Event.OnSwitchView event

Office 2013 and later

Occurs after a view in a Microsoft InfoPath form has been successfully switched.

Namespace:  Microsoft.Office.Interop.InfoPath.SemiTrust
Assembly:  Microsoft.Office.Interop.InfoPath.SemiTrust (in Microsoft.Office.Interop.InfoPath.SemiTrust.dll)

event _XDocumentEventSink2_OnSwitchViewEventHandler OnSwitchView

This event handler does not allow users to cancel an operation.

NoteNote

The OnSwitchView event also occurs when a form is first opened.

In the following example, the OnSwitchView event handler is used to show the name of the view displayed when the view change occurs:

[InfoPathEventHandler(EventType=InfoPathEventType.OnSwitchView)]
public void OnSwitchView(DocEvent e)
{
 thisXDocument.UI.Alert("Loading the view " + thisXDocument.View.Name);
}
Show: