<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: VSTA "ReplaceSelf" programming issue/ clearing section fields challenge</title><link>https://www.infopathdev.com:443/forums/thread/48223.aspx</link><pubDate>Mon, 26 Oct 2009 13:40:39 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:48223</guid><dc:creator>seidensc</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/48223.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=48223</wfw:commentRss><description>&lt;p&gt;Thanks again Jimmy; you&amp;#39;ve been very helpful!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: VSTA "ReplaceSelf" programming issue/ clearing section fields challenge</title><link>https://www.infopathdev.com:443/forums/thread/48189.aspx</link><pubDate>Sat, 24 Oct 2009 02:31:31 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:48189</guid><dc:creator>Jimmy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/48189.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=48189</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Are you saying you&amp;#39;re looking for the thisXDocument.UI.confirm() function?&lt;/p&gt;
&lt;p&gt;In IP 2007 you should just use the usual System.Windows.Forms API:&lt;/p&gt;
&lt;blockquote&gt;&lt;font size="2"&gt;
&lt;/font&gt;&lt;p&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;DialogResult&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; response = &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;MessageBox&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.Show(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;Are you sure you want to do this?&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.Empty, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;MessageBoxButtons&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.YesNo);&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;if&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; (response == &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;DialogResult&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.Yes)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#008000" size="2"&gt;// Do stuff&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;}&lt;/font&gt;&lt;/p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/blockquote&gt;</description></item><item><title>Re: VSTA "ReplaceSelf" programming issue/ clearing section fields challenge</title><link>https://www.infopathdev.com:443/forums/thread/48180.aspx</link><pubDate>Fri, 23 Oct 2009 19:52:32 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:48180</guid><dc:creator>seidensc</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/48180.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=48180</wfw:commentRss><description>&lt;p&gt;The other groups are now working too with a little help with the debugger.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;I&amp;#39;m still stuck on how to throw up a ok/cancel that the fields are about to be cleared by collapsing a section.&amp;nbsp; If you can shed any light on how to do this it would be appreciated.&amp;nbsp; Note environment on my last post...&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: VSTA "ReplaceSelf" programming issue/ clearing section fields challenge</title><link>https://www.infopathdev.com:443/forums/thread/48179.aspx</link><pubDate>Fri, 23 Oct 2009 19:19:17 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:48179</guid><dc:creator>seidensc</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/48179.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=48179</wfw:commentRss><description>&lt;p&gt;Thanks for your reply Jimmy.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;I added the logic to the Changed event as you indicated.&amp;nbsp; It worked well.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;On to adding the other groups.&amp;nbsp; This was not too successful.&amp;nbsp; I have to spend some time to see what I did wrong; not sure what, but all I did was copy the code and paste the names in from xcopy.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;I also looked at the ok/cancel functionality.&amp;nbsp; So far I can&amp;#39;t find out how to instantiate xdocument to get at the UI.&amp;nbsp; It looks like it should be automatic but under VS2008/InfoPath 2007 it is not.&amp;nbsp; I&amp;#39;m not familiar enough with the API to know if it was moved, changed, or what.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Anyway, a big thank you for making my day brighter with the tibit you passed along.&lt;/p&gt;
&lt;p&gt;Steve&lt;/p&gt;</description></item><item><title>Re: VSTA "ReplaceSelf" programming issue/ clearing section fields challenge</title><link>https://www.infopathdev.com:443/forums/thread/48173.aspx</link><pubDate>Fri, 23 Oct 2009 00:33:09 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:48173</guid><dc:creator>Jimmy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/48173.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=48173</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;InfoPath will not allow you to change the contents of the data source in a &lt;b&gt;Changing &lt;/b&gt;event.&amp;nbsp; Please try adding that code to AcademicPerformance&amp;#39;s &lt;b&gt;Changed&lt;/b&gt; event.&lt;br /&gt;&lt;/p&gt;</description></item><item><title>VSTA "ReplaceSelf" programming issue/ clearing section fields challenge</title><link>https://www.infopathdev.com:443/forums/thread/48164.aspx</link><pubDate>Thu, 22 Oct 2009 18:20:32 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:48164</guid><dc:creator>seidensc</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/48164.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=48164</wfw:commentRss><description>&lt;p&gt;This is my first InfoPath form.&amp;nbsp; We have InfoPath as part of our desktop install.&amp;nbsp; SharePoint is coming but will not be here until next year.&amp;nbsp; I also have VSTA installed.&amp;nbsp; I state this in case it makes a difference on this post.&lt;/p&gt;
&lt;p&gt;I have the following fields/containers within the myfields container:&lt;/p&gt;
&lt;p&gt;AcademicPerformance (Check box)&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;AcademicPerformanceGroup&lt;br /&gt;&amp;nbsp; &amp;nbsp; CurrentGrade*&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Tutor (Check box)&lt;br /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;TutorGroup&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;TutorName&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TutorPersonID&lt;/p&gt;
&lt;p&gt;On the AcademicPerformanceGroup I have conditional formatting which hides the section if the AcademicPerformance check box is false.&amp;nbsp; What I have noticed is that if a &amp;quot;form filler&amp;quot; enters info into the Academic Performance and Tutor groups and then uncheck the Academic Performance check box the section is collapsed but the data remains.&amp;nbsp; I would like the default behavior of unchecking the box to throw up a warning (next programming iteration) and then clear the subordinate fields before collapsing.&lt;/p&gt;
&lt;p&gt;This is what I have come up with so far:&lt;/p&gt;
&lt;p&gt;using Microsoft.Office.InfoPath;&lt;br /&gt;using System;&lt;br /&gt;using System.Windows.Forms;&lt;br /&gt;using System.XML;&lt;br /&gt;using System.Xml.XPath;&lt;br /&gt;using mshtml;&lt;/p&gt;
&lt;p&gt;namespace StudentReferral&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; public partial class FormCode&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private string initialAPData;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void InternalStartup()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; EventManager.XmlEvents[&amp;quot;/my:myFields/my:AcademicPerformance&amp;quot;].Changing += new XmlChangingEventHandler(AcademicPerformance_Changing);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; EventManager.FormEvents.Loading += new LoadingEventHandler(FormEvents_Loading);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void AcademicPerformance_Changing(object sender, XmlChangingEventArgs e)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; String fieldValue = MainDataSource.CreateNavigator().SelectSingleNode(&amp;quot;/my:myFields/my:AcademicPerformance&amp;quot;, NamespaceManager).Value;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (fieldValue == &amp;quot;false&amp;quot;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;MainDataSource.CreateNavigator().SelectSingleNode(&amp;quot;/my:myFields/my:AcademicPerformanceGroup&amp;quot;, NamespaceManager).ReplaceSelf(initialAPData);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void FormEvents_Loading(object sender, LoadingEventArgs e)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; initialAPData = MainDataSource.CreateNavigator().SelectSingleNode(&amp;quot;/my:myFields/my:AcademicPerformanceGroup&amp;quot;, NamespaceManager).OuterXml;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;First of all, is there a better way of clearing several containers/fields within a section(s) rather than resorting to code?&amp;nbsp; &lt;br /&gt;If not, I am getting a little error that if someone can see I would greatly appreciate it.&amp;nbsp; Once I get beyond the error I plan to add an ok/cancel dialog and then add the code to all my expanding sections.&lt;/p&gt;
&lt;p&gt;When the &amp;quot;MainDataSource.CreateNavigator().SelectSingleNode(&amp;quot;/my:myFields/my:AcademicPerformanceGroup&amp;quot;, NamespaceManager).ReplaceSelf(initialAPData);&amp;quot; statement executes I receive the following error:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;A first chance exception of type &amp;#39;System.InvalidOperationException&amp;#39; occurred in Microsoft.Office.InfoPath.Client.Internal.Host.Interop.dll&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;InitialAPData (after the form load event) =&lt;br /&gt;&amp;lt;my:AcademicPerformanceGroup xmlns:my=&amp;quot;&lt;a href="http://schemas.microsoft.com/office/infopath/2003/myXSD/2009-09-28T17:12:30"&gt;http://schemas.microsoft.com/office/infopath/2003/myXSD/2009-09-28T17:12:30&lt;/a&gt;&amp;quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;my:CurrentGrade&amp;gt;&amp;lt;/my:CurrentGrade&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;my:Tutor&amp;gt;false&amp;lt;/my:Tutor&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;my:TutorGroup&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;my:TutorName&amp;gt;&amp;lt;/my:TutorName&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;my:TutorPersonID xmlns:xsi=&amp;quot;&lt;a href="http://www.w3.org/2001/XMLSchema-instance"&gt;http://www.w3.org/2001/XMLSchema-instance&lt;/a&gt;&amp;quot; xsi:nil=&amp;quot;true&amp;quot;&amp;gt;&amp;lt;/my:TutorPersonID&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;/my:TutorGroup&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;lt;/my:AcademicPerformanceGroup&amp;gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;Any ideas why this error would be encountered?&amp;nbsp; &lt;/p&gt;</description></item></channel></rss>