Sunday, October 14, 2012

Switch to show a specific view when a form opens

Problem: You have an InfoPath form that has two views and you want to be able to set the InfoPath form to start up with and show one of these two views.

You can use the SetDefaultView() method of the LoadingEventArgs object in the FormEvents_Loading() event handler of a form to switch to a particular view when the form opens.

1 - Add a new view called "View 2"

2 - Add the following code to the FormEvents_Loading() event handler

 e.SetDefaultView("View 2")

3 - Preview the form, when it opens View 2 will appear.

No comments:

Post a Comment

About Me

My photo
Toronto, Ontario, Canada
MBA, M.Sc. & MCP