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 / September 2004

Tip: Looking for answers? Try searching our database.

selectNode fails after switchView

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
GGian - 28 Sep 2004 14:49 GMT
I have a small piece of code that gets called form my custom task pane. This
code is supposed to change the current view and then select a certain node
within the form. I have two buttons, (button1)one just switches the view and
(button2)the other switches the view and selects a node. If i click button2,
then it will switch the view but then fail when SelectNodes is called.
Strangely, if i click button1 and then button2 then button2 works as
expected. Is there some problem with switching views and selecting a node in
the same function? I have attached the code i use for slecting a node below.
Thanks for your help.
-Greg G

IXMLDOMNode tmpNode = thisXDocument.DOM.selectSingleNode( "//"+nodeName);
thisXDocument.View.SelectNodes(tmpNode,Type.Missing,Type.Missing);
Greg Collins [MVP] - 28 Sep 2004 22:36 GMT
If I understand you correctly, you have 2 views.
Both View 1 and View 2 contain Button1 and Button2.

View 1:
Button 1 switches to View 2.
Button 2 switches to View 2 and selects a field

View 2:
Button 1 switches to View 1.
Button 2 selects a field in View 2.

I believe the problem with View1/Button2 is a timing issue. While the view has not yet been built, the code is attempting to select a field (which doesn't yet exist). I ran into a similar issue in my InfoPathDev.com Example, "Fully Editable Drop-Down List Box".

The reason View2/Button2 works (as described above) is because the field exists when the attempt is made to select it.

In order to get View1/Button2 to work, you can try setting a flag, and then in the OnSwitchView event handler, verify you are in View2, check for the flag, and then select the field. I believe at this point the view is completely built and the field will be selected without an error.

Let me know the results when you've tried this.

Signature

Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com

I have a small piece of code that gets called form my custom task pane. This
code is supposed to change the current view and then select a certain node
within the form. I have two buttons, (button1)one just switches the view and
(button2)the other switches the view and selects a node. If i click button2,
then it will switch the view but then fail when SelectNodes is called.
Strangely, if i click button1 and then button2 then button2 works as
expected. Is there some problem with switching views and selecting a node in
the same function? I have attached the code i use for slecting a node below.
Thanks for your help.
-Greg G

IXMLDOMNode tmpNode = thisXDocument.DOM.selectSingleNode( "//"+nodeName);
thisXDocument.View.SelectNodes(tmpNode,Type.Missing,Type.Missing);

Rate this thread:






 
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.