Application.RegisterFormTemplate 方法

定义

重载

RegisterFormTemplate(String)

安装指定的表单模板。

RegisterFormTemplate(String, String)

安装指定的表单模板,并选中覆盖表单模板的先前注册记录的选项。

RegisterFormTemplate(String)

安装指定的表单模板。

public:
 abstract void RegisterFormTemplate(System::String ^ formTemplateLocation);
public abstract void RegisterFormTemplate(string formTemplateLocation);
abstract member RegisterFormTemplate : string -> unit
Public MustOverride Sub RegisterFormTemplate (formTemplateLocation As String)

参数

formTemplateLocation
String

指定表单模板的统一资源定位器 (URL)。 可以将此参数指定为表单定义 (.xsf) 文件或表单模板 (.xsn) 文件。

例外

找不到表单模板文件。

传递给此方法的参数是一个 null 引用, (Visual Basic) 中无任何内容。

传递给此方法的参数无效。 例如,它的类型或格式有误。

注解

如果已经注册表单模板,则表单模板的注册记录将被覆盖。 若要控制是否覆盖以前注册的表单模板的记录,请改用 RegisterFormTemplate(String, String) 方法。

只能由从表单模板打开的表单访问此成员,已使用“表单选项”对话框“安全和信任”类别将该模板配置为以完全信任状态运行。 此成员要求直接调用方的完全信任并且不能由部分信任的代码使用。 有关更多信息,请参阅 MSDN 上的“使用部分信任的代码中的库”。

可以通过 Microsoft InfoPath Filler 中打开的表单中运行的代码访问此类型或成员。

适用于

RegisterFormTemplate(String, String)

安装指定的表单模板,并选中覆盖表单模板的先前注册记录的选项。

public:
 abstract void RegisterFormTemplate(System::String ^ formTemplateLocation, System::String ^ behavior);
public abstract void RegisterFormTemplate(string formTemplateLocation, string behavior);
abstract member RegisterFormTemplate : string * string -> unit
Public MustOverride Sub RegisterFormTemplate (formTemplateLocation As String, behavior As String)

参数

formTemplateLocation
String

指定表单模板的统一资源定位器 (URL)。 可以将此参数指定为表单定义 (.xsf) 文件或表单模板 (.xsn) 文件。

behavior
String

指定安装表单模板的方法。 默认值为“overwrite”。 此参数仅有两个有效值,另一个为“new-only”。

例外

找不到表单模板文件。

传递给此方法的参数是 null 引用, (Visual Basic) 中没有。

传递给此方法的参数无效。 例如,它们的类型或格式有误。

示例

在以下示例中,类的 ApplicationRegisterFormTemplate 方法在函数中使用来安装表单模板。 该示例假定在包含函数的类的声明部分中有一个 usingImports 语句 ,用于Microsoft.Office.InfoPath 命名空间,并且 Visual Studio 中“添加引用”对话框的 COM 选项卡上引用了 Microsoft InfoPath 3.0 类型库。

public void InstallForm()
{
Microsoft.Office.InfoPath.Application infoPathApp = 
   new Microsoft.Office.InfoPath.Application();
infoPathApp.RegisterFormTemplate(@"C:\My Forms\MyFormTemplate.xsn", 
   "overwrite");
}
Public Sub InstallForm()
Dim infoPathApp As Microsoft.Office.InfoPath.Application = _
   new Microsoft.Office.InfoPath.Application()
infoPathApp.RegisterFormTemplate("C:\My Forms\MyFormTemplate.xsn", _
   "overwrite")
End Sub

注解

如果表单模板已注册,并且为 behavior 参数指定了“new-only”, 则 RegisterFormTemplate 方法将返回错误。 如果参数指定为“overwrite”,将覆盖表单模板的注册记录。

只能由从表单模板打开的表单访问此成员,已使用“表单选项”对话框“安全和信任”类别将该模板配置为以完全信任状态运行。 此成员要求直接调用方的完全信任并且不能由部分信任的代码使用。 有关更多信息,请参阅 MSDN 上的“使用部分信任的代码中的库”。

可以通过 Microsoft InfoPath Filler 中打开的表单中运行的代码访问此类型或成员。

适用于