How to change the data for an opened InfoPath form/template hosted by a Winform RRS feed

  • Question

  • We have a InfoPath form that is hosted with WinForms.  It loads slowly but our most common case is to show different data in it.

    If we could load it once, but then change the data displayed, the performance wouldn't be an issue.  However right now, to display different data, we have to close the form and re-open it causing the full InfoPath load template etc to be repeated.

    In our case, the XML is for different citations that will be displayed.  The form and template don't change, only the data.

    I've tried to change the underlying XML in a number of ways, such as:

            var infoPathXml = InfoPathFormControl.XmlForm.MainDataSource.CreateNavigator();
            infoPathXml.OuterXml = xml_data_to_display;

    where the xml_data_to_display is the XML we want to view.

    We've also tried using the navigator to replace the XML such as:

            var infoPathXml = InfoPathFormControl.XmlForm.MainDataSource.CreateNavigator();
            var manager = new System.Xml.XmlNamespaceManager(infoPathXml.NameTable);
            manager.AddNamespace("my", InfoPathNamespace);

            var node = infoPathXml.SelectSingleNode("//my:SCRPT_Source", manager);

    However all our efforts have ended with exceptions from InfoPath. 

    Basically, we use the NewFromFormTemplate(template, data, options) method to create the initial form and want a way to change data that is supplied to the form after its been created.

    For instance, can we create a form and the programmatically add the data to it?  The only way I've found to populate the form's data controls is with NewFromFormTemplate().

    Any ideas?



    Monday, July 1, 2013 4:10 PM

All replies