次の方法で共有


XmlFormCollection.NewFromFormTemplate メソッド (String, XPathNavigator)

指定したフォーム テンプレートと XPathNavigator オブジェクトで指定されるデータを使用して新しいフォームを作成します。

名前空間: Microsoft.Office.InfoPath
アセンブリ: Microsoft.Office.InfoPath (microsoft.office.infopath.dll 内)

構文

'宣言
Public MustOverride Function NewFromFormTemplate ( _
    formTemplateLocation As String, _
    xmlData As XPathNavigator _
) As XmlForm
'使用
Dim instance As XmlFormCollection
Dim formTemplateLocation As String
Dim xmlData As XPathNavigator
Dim returnValue As XmlForm

returnValue = instance.NewFromFormTemplate(formTemplateLocation, xmlData)
public abstract XmlForm NewFromFormTemplate (
    string formTemplateLocation,
    XPathNavigator xmlData
)

パラメータ

  • formTemplateLocation
    新しいフォームの基になるフォーム テンプレートの URI (Uniform Resource Identifier)。
  • xmlData
    フォームのテンプレートとして使用される XML データを返す XPathNavigator オブジェクト。

戻り値

作成された新しいフォームを表す XmlForm オブジェクト。

コメント

NewFromFormTemplate メソッドは、既存のフォーム テンプレートに基づいて新しいフォームを作成するためにのみ使用でき、フォームに基づいて新しいフォームを作成するためには使用できません。既存のフォームからフォームを作成するには、New メソッドを使用します。

NewFromFormTemplate メソッドを使用すると、InfoPath で新しいフォームが開き、入力できる状態になります。

このメンバは、現在開いているフォームと同じドメイン内で実行されているフォーム、またはドメインを越えたアクセス許可を付与されているフォームだけがアクセスできます。

この型またはメンバは、Microsoft Office InfoPath 2007 で開いているフォームで実行されているコードからのみアクセスできます。

次の例では、XmlFormCollection クラスの NewFromFormTemplate(formTemplateLocation, xmlData) メソッドに既存のフォーム テンプレートの URI および XML データを返す XPathNavigator オブジェクトの URI を渡し、新しいフォームに関連付けられた XmlForm オブジェクトが返されます。

// Create an in-memory XML document.
XmlDocument newDoc = new XmlDocument();
// Load the document with some XML.
newDoc.LoadXml(
   "<?xml version=\"1.0\" encoding=\"utf-8\" ?><person><firstName/><lastName/><address/><city/><country/></person>");
// Create an XPathNavigator for the XML file.
XPathNavigator newDocNav = newDoc.CreateNavigator();
// Call NewFromFormTemplate to open new form and load XML.
XmlForm newDocument = 
   this.Application.XmlForms.NewFromFormTemplate(
   @"C:\MyForm.xsn", newDocNav);
' Create an in-memory XML document.
Dim newDoc As XmlDocument = new XmlDocument()
' Create XML to load.
Dim xmlToLoad As String = "<?xml version=" & Quote & "1.0" & Quote & _
   " encoding=" & Quote & "utf-8" & Quote & _
   " ?><person><firstName/><lastName/><address/>" & _
   "<city/><country/></person>"
' Load the document with some XML.
newDoc.LoadXml(
   )
' Create an XPathNavigator for the XML file.
Dim newDocNav As XPathNavigator  = newDoc.CreateNavigator()

' Call NewFromFormTemplate to open new form and load XML.
Dim newDocument As XmlForm  = _
   Me.Application.XmlForms.NewFromFormTemplate(_
   "C:\MyForm.xsn", newDocNav)

関連項目

参照

XmlFormCollection クラス
XmlFormCollection のメンバ
Microsoft.Office.InfoPath 名前空間