Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / November 2007

Tip: Looking for answers? Try searching our database.

how to programatically switch view on load

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Fred - 12 Nov 2007 19:10 GMT
I don't understand how to load a view by using the from openning
rules. But the rule itself is not dynamically enough. The best options
is that I can control using code in the form load events. So I write
the following code to handle the form load event, like the following.

XPathNavigator nav = this.MainDataSource.CreateNavigator();
string viewName = nav.SelectSingleNode("/my:myFields/my:View",
NamespaceManager).Value;
MessageBox.Show("entering switchview");
if (!string.IsNullOrEmpty(viewName))
{
   this.ViewInfos.SwitchView(viewName);
   this.ViewInfos.Initial = this.ViewInfos[viewName];
}

This section of code works if they handle a button click event, but it
does not work in Form load event, and there is no exception displayed?

Does anyone have this kind experience before?

thanks
Fred - 12 Nov 2007 19:37 GMT
I have solve this issue, it turns out that I can not use the form
loading event, and secondly, I should
use  this.ViewInfos.Initial  property.

void FormCode_Startup(object sender, EventArgs e)
{
   XPathNavigator nav = this.MainDataSource.CreateNavigator();
   string viewName = nav.SelectSingleNode("/my:myFields/my:View",
NamespaceManager).Value;
   if (!string.IsNullOrEmpty(viewName))
   {
       this.ViewInfos.Initial = this.ViewInfos[viewName];
   }
}

Thanks

> I don't understand how to load a view by using the from openning
> rules. But the rule itself is not dynamically enough. The best options
[quoted text clipped - 18 lines]
>
> thanks
Mackenzie, Jason - 12 Nov 2007 19:58 GMT
You need to wireup the form load event in the startup event:

       public void InternalStartup()
       {
           EventManager.FormEvents.Loading += new
LoadingEventHandler(FormEvents_Loading);

       }
>I have solve this issue, it turns out that I can not use the form
> loading event, and secondly, I should
[quoted text clipped - 35 lines]
>>
>> thanks
Fred - 13 Nov 2007 04:45 GMT
Thanks for reminding that. Actually, my test will of cause ensure that
handler get called. The problem is not the handler can not be called,
but the behavior of the handler.
I have test that the in the Loading event, the form switching
techniques like the following has not effect
this.ViewInfos.SwitchView(viewName);
or     this.ViewInfos.Initial = this.ViewInfos[viewName];
but they are legal event in Form service.

StartUp event can solve the problem in InfoPath client, be can not
used in form service. That is dilemma.

Thanks

> You need to wireup the form load event in the startup event:
>
[quoted text clipped - 44 lines]
>
> - Show quoted text -
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.