Share via


SubmitToHostAdapterObject 接口

此类型是用于 Coclass(托管代码需要此 Coclass 来实现 COM 互操作性)的包装。使用此类型来访问由此 Coclass 实现的 COM 接口。有关 COM 接口的信息(包括指向其成员说明的链接),请参阅SubmitToHostAdapter.

命名空间:  Microsoft.Office.Interop.InfoPath.SemiTrust
程序集:  Microsoft.Office.Interop.InfoPath.SemiTrust(位于 Microsoft.Office.Interop.InfoPath.SemiTrust.dll 中)

语法

声明
<GuidAttribute("096cd739-0786-11d1-95fa-0080c78ee3bb")> _
Public Interface SubmitToHostAdapterObject _
    Inherits SubmitToHostAdapter
用法
Dim instance As SubmitToHostAdapterObject
[GuidAttribute("096cd739-0786-11d1-95fa-0080c78ee3bb")]
public interface SubmitToHostAdapterObject : SubmitToHostAdapter

备注

该类型的连接在表单模板中使用,表单模板由将 InfoPath 表单编辑环境当作控件来承载的应用程序打开。有关将 InfoPath 当作控件来承载的信息,包括如何在主机应用程序的代码中创建一个方法来处理提交表单的事件,请参阅 MSDN 上的 InfoPath 开发人员门户(该链接可能指向英文页面)中标题为"在自定义 WinForm 应用程序中承载 InfoPath 表单编辑环境"的文章。

要创建一个向宿主环境提交数据、并且可以从表单模板中的业务逻辑引用的数据连接,请使用"工具"菜单上的"数据连接"命令。有关如何创建当 OnSubmitRequest 事件引发时将运行的事件处理程序的信息,请参阅如何:使用 InfoPath 2003 对象模型添加事件处理程序

示例

下面的示例显示了一种代码编写模式,它将在提交表单之前在表单模板的业务逻辑中执行自定义操作。

[InfoPathEventHandler(EventType = InfoPathEventType.OnSubmitRequest]
public void FormEvents_OnSubmitRequest(DocReturnEvent e)
{
   // Get the data adapter defined in the form template from the 
   // DataAdapters collection and cast to the SubmitToHostAdapter
   // type.
   SubmitToHostAdapter submitAdapter = 
      (SubmitToHostAdapter)(DataAdapters["MyHostAdapter"]);

   // Write code here to do custom actions that are not 
   // supported by rules or other declarative settings.  

   // Execute the submit operation against the adapter.
   submitAdapter.Submit();

}

<InfoPathEventHandler(EventType := InfoPathEventType.OnSubmitRequest)>
Public Sub FormEvents_OnSubmitRequest(ByVal e As DocReturnEvent)
   ' Get the data connection defined in the form template from the
   ' DataAdapters collection and cast to the SubmitToHostAdapter
   ' type.
   Dim submitAdapter As SubmitToHostAdapter = _
      DirectCast(DataAdapters("MyHostAdapter"), _
      SubmitToHostAdapter)

   ' Write code here to do custom actions that are not 
   ' supported by rules or other declarative settings.

   ' Execute the submit operation against the connection.
   submitAdapter.Submit()
End Sub

另请参阅

引用

SubmitToHostAdapterObject 成员

Microsoft.Office.Interop.InfoPath.SemiTrust 命名空间