W
Wozza
I have a dropdown listbox, and am trying to change views based on the value
selected ... but am getting the error below. I read that there are no
restrictions on changing views in a Changed event ...?? Is this correct. If
so why am I getting this error?
System.Runtime.InteropServices.COMException
Invalid context for OM call.
at Microsoft.Office.Interop.InfoPath.SemiTrust.View.SwitchView(String
bstrName)
at
Microsoft.Office.Interop.InfoPath.SemiTrust.ViewObjectWrapper.SwitchView(String
bstrName)
at
Microsoft.Office.InfoPath.Internal.ViewInfoCollectionHost.SwitchView(String
name)
at PagingThruViews.FormCode.INDEX_Changed(Object sender, XmlEventArgs e)
at Microsoft.Office.InfoPath.Internal.XmlEventHost.GenericProxy(Object
genericDelegate, DataDOMEvent dataDOMEvent, InfoPathEvents type)
at
Microsoft.Office.InfoPath.Internal.XmlEventHost.ChangedProxy(DataDOMEvent
dataDOMEvent)
at
Microsoft.Office.Interop.InfoPath.SemiTrust._DataDOMEventSink_SinkHelper.OnAfterChange(DataDOMEvent
pDataDOMEvent)
My code is (I have "View 1" and "View 2"):
public void InternalStartup()
{
EventManager.XmlEvents["/TEST/INDEX"].Changed += new
XmlChangedEventHandler(INDEX_Changed);
}
public void INDEX_Changed(object sender, XmlEventArgs e)
{
this.ViewInfos.SwitchView(@"View " + e.NewValue.ToString().Trim());
}
selected ... but am getting the error below. I read that there are no
restrictions on changing views in a Changed event ...?? Is this correct. If
so why am I getting this error?
System.Runtime.InteropServices.COMException
Invalid context for OM call.
at Microsoft.Office.Interop.InfoPath.SemiTrust.View.SwitchView(String
bstrName)
at
Microsoft.Office.Interop.InfoPath.SemiTrust.ViewObjectWrapper.SwitchView(String
bstrName)
at
Microsoft.Office.InfoPath.Internal.ViewInfoCollectionHost.SwitchView(String
name)
at PagingThruViews.FormCode.INDEX_Changed(Object sender, XmlEventArgs e)
at Microsoft.Office.InfoPath.Internal.XmlEventHost.GenericProxy(Object
genericDelegate, DataDOMEvent dataDOMEvent, InfoPathEvents type)
at
Microsoft.Office.InfoPath.Internal.XmlEventHost.ChangedProxy(DataDOMEvent
dataDOMEvent)
at
Microsoft.Office.Interop.InfoPath.SemiTrust._DataDOMEventSink_SinkHelper.OnAfterChange(DataDOMEvent
pDataDOMEvent)
My code is (I have "View 1" and "View 2"):
public void InternalStartup()
{
EventManager.XmlEvents["/TEST/INDEX"].Changed += new
XmlChangedEventHandler(INDEX_Changed);
}
public void INDEX_Changed(object sender, XmlEventArgs e)
{
this.ViewInfos.SwitchView(@"View " + e.NewValue.ToString().Trim());
}