ViewInfoCollection.SwitchView method (String)

Office 2013 and later

Switches the current view to the specified view by name.

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

public abstract void SwitchView(
	string name
)

Parameters

name
Type: System.String

The name of the view to switch to.

ExceptionCondition
ArgumentException

The view name does not exist.

InvalidOperationException

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

ArgumentNullException

The parameter passed to this method is a null reference (Nothing in Visual Basic).

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 InfoPath Filler or in a Web browser.

The following example switches the current view to the view name "View2".

this.ViewInfos.SwitchView("View2");
Show: