We recommend using Visual Studio 2017

LoadingEventArgs.SetDefaultView Method (String) (Microsoft.Office.InfoPath)

Sets the default view of the form by specifying the name of the view.

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

public abstract void SetDefaultView (
	string view



The name of the view.

Exception typeCondition


The parameter passed to this method is null.


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

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

In the following example, the SetDefaultView(System.String) method is used in the Loading event handler to set the default view to the view named "View2".

public void FormEvents_Loading(object sender, LoadingEventArgs e)