Thursday, September 9, 2010

Setting views dynamically in infopath form through code

When working with infopath forms, there are lot of things we have to know. This is not very easy to implement, publish and using it. So, we have to know complete details about infopath in all aspects. I had a requirement in infopath, while loading depends on some scenario I have to switch the view. While form is loading I have logic written to know what view I have to set. But, once I got the view name from logic, how to set that to infopath form? Below is the simple code which works for that requirement.
the "e" used in this code is the LoadingEventArgs object in the form event. It has the method named SetDefaultView(), Which takes the view name as the parameter. So, once you set it, it will apply the view to the infopath and display the view on the form.

Hope this helps to understand better the infopath and code.

No comments:

Post a Comment