XmlForm.MergeForm Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
MergeForm(String) |
Merges the current form with the form specified by path or URL. |
MergeForm(XPathNavigator) |
Merges the current form with the target form specified in the node returned by the XPathNavigator passed to the method. |
MergeForm(String)
Merges the current form with the form specified by path or URL.
public:
abstract void MergeForm(System::String ^ fileUrl);
public abstract void MergeForm (string fileUrl);
abstract member MergeForm : string -> unit
Public MustOverride Sub MergeForm (fileUrl As String)
Parameters
- fileUrl
- String
The path or URL to the form file to merge.
Exceptions
The value passed for fileUrl
is a null reference (Nothing in Visual Basic).
The value passed for fileUrl
is "" or is invalid.
The MergeForm method was called from the Loading event.
Examples
In the following code example, the MergeForm method of the XmlForm class is used to merge a form with the current form.
this.MergeForm("C:\\MyForms\\SomeOtherForm.xml");
Me.MergeForm("C:\MyForms\SomeOtherForm.xml")
Remarks
The MergeForm method is equivalent to using the Merge Forms command of the InfoPath form editor. The value passed as the fileUrl
parameter must be a full path or URL, and must include the filename with an .xml file extension.
This member can be accessed only by forms running in the same domain as the currently open form, or by forms that have been granted cross-domain permissions.
This type or member can be accessed only from code running in forms opened in Microsoft InfoPath Filler.
Applies to
MergeForm(XPathNavigator)
Merges the current form with the target form specified in the node returned by the XPathNavigator passed to the method.
public:
abstract void MergeForm(System::Xml::XPath::XPathNavigator ^ target);
public abstract void MergeForm (System.Xml.XPath.XPathNavigator target);
abstract member MergeForm : System.Xml.XPath.XPathNavigator -> unit
Public MustOverride Sub MergeForm (target As XPathNavigator)
Parameters
- target
- XPathNavigator
An XPathNavigator that provides the XML data to merge into the current form.
Exceptions
The MergeForm method was called from the Loading event.
The parameter passed to this method is a null reference (Nothing in Visual Basic).
The parameter passed to this method is not valid. For example, it is of the wrong type or format.
Examples
In the following code example, a System.Xml.XmlDocument object is used to load a form from the specified URL, and then a System.Xml.XPath.XPathNavigator object is positioned at the root of the form to merge. Finally, the XPathNavigator is passed to the MergeForm(System.Xml.XPath.XPathNavigator) method to merge the form into the current form.
string pathToFile = @"C:\FormToMerge\Form1.xml";
XmlDocument FormXML = new XmlDocument();
// The form tempate must be Full Trust for the
// XmlDocument.Load method to work.
FormXML.Load(pathToFile);
XPathNavigator nav = FormXML.CreateNavigator();
// Merge the root node (the entire document) into the current form.
this.MergeForm(nav);
Dim pathToFile As String = "C:\FormToMerge\Form1.xml"
Dim FormXML As New XmlDocument
' The form tempate must be Full Trust for the
' XmlDocument.Load method to work.
FormXML.Load(pathToFile)
Dim nav As XPathNavigator = FormXML.CreateNavigator()
' Merge the root node (the entire document) into the current form.
Me.MergeForm(nav)
Remarks
The MergeForm method is equivalent to using the Merge Forms command of the InfoPath editor. The XML data provided by XPathNavigator passed as the target
parameter must be valid XML for merging into the current form. If the XML data provided isn't wrapped as an InfoPath form, InfoPath will wrap the data.
This member can be accessed only by forms running in the same domain as the currently open form, or by forms that have been granted cross-domain permissions.
This type or member can be accessed only from code running in forms opened in Microsoft InfoPath Filler.