共用方式為


SubmitToHostAdapterObject 介面

代表用來送出資料至主機環境的連線。

**命名空間:**Microsoft.Office.Interop.InfoPath
**組件:**Microsoft.Office.Interop.InfoPath (於 microsoft.office.interop.infopath.dll 中)

語法

'宣告
<GuidAttribute("096CD739-0786-11D1-95FA-0080C78EE3BB")> _
<CoClassAttribute(GetType(SubmitToHostAdapterObjectClass))> _
Public Interface SubmitToHostAdapterObject
    Inherits SubmitToHostAdapter
'用途
Dim instance As SubmitToHostAdapterObject
[GuidAttribute("096CD739-0786-11D1-95FA-0080C78EE3BB")] 
[CoClassAttribute(typeof(SubmitToHostAdapterObjectClass))] 
public interface SubmitToHostAdapterObject : SubmitToHostAdapter

備註

此類型為 coclass 的包裝函式,屬於 COM 互通性中 Managed 程式碼的必要項。使用此類型,即可存取由此 coclass 實作的 COM 介面成員。如需 COM 介面 (包括其成員說明連結) 的詳細資訊,請參閱 SubmitToHostAdapter

在將 InfoPath 表單編輯環境裝載成控制項之應用程式所開啟的表單範本中,會使用這種類型的連線。如需將 InfoPath 裝載成控制項的詳細資訊,包括如何在主應用程式的程式碼中建立方法以處理送出表單之事件的詳細資訊,請參閱 MSDN 上的文章在自訂應用程式中裝載 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 命名空間