We recommend using Visual Studio 2017

ViewInfoCollection.SwitchView Method (ViewInfo) (Microsoft.Office.InfoPath)

Switches the current view to the view represented by the specified ViewInfo object.

Namespace: Microsoft.Office.InfoPath
Assembly: Microsoft.Office.InfoPath (in microsoft.office.infopath.dll)

public abstract void SwitchView (
	ViewInfo view
)

Parameters

view

The ViewObject that represents the view to switch to.

Exception typeCondition

InvalidOperationException

The SwitchView method was called from an event handler for the Loading or ViewSwitched events.

ArgumentNullException

The parameter passed to this method is null.

ArgumentException

The parameter passed to this method isnot valid. For example, it is of the wrong type or format.

This member can be accessed only by forms running in the same domain as the currently open form, or by forms that have been granted cross-domain permissions.

This type or member can be accessed from code running in forms opened in Microsoft Office InfoPath 2007 or in a Web browser.

The following example switches the current view to the initial view in the ViewInfoCollection collection using the Initial property to get the ViewInfo object that represents the initial view in the collection.

ViewInfo firstView = ViewInfos.Initial;
this.ViewInfos.SwitchView(firstView);
Show: