how to programatically switch view on load

F

Fred

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
 
F

Fred

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
 
M

Mackenzie, Jason

You need to wireup the form load event in the startup event:

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


}
Fred said:
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
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
 
F

Fred

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:

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
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];
}
}

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- Hide quoted text -

- Show quoted text -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top