Hi there,
I know this might be extremely obvious to most of you, but for me as a newcomer to InfoPath Development i thought I'd just add the following, just as a matter of being pedantic about getting things right:
This code above works well in the Load event ( e.SetDefaultView("viewName") ), but if you are going to set the default view based on certain values, don't forget to set the "main" default view for the form somewhere at the top of your code.
I dont know how better to explain this, so let me use an example:
//All your initialization happens here...
//Now we need to set the "main" default view...
e.SetDefaultView("view1");
//you have the condition for when the default view should change
if (somevalue)
e.SetDefaultView("view2");
Remember that should you just set the default view without initializing it, the next time the form is opened, it will open "view2", which was a bit unexpected for a beginner like me.
Thanks for this great site!
life happens...