ContentControlContentUpdatingEventArgs 介面

提供內容控制項的 ContentUpdating 事件資料。

命名空間:  Microsoft.Office.Tools.Word
組件:  Microsoft.Office.Tools.Word (在 Microsoft.Office.Tools.Word.dll 中)

語法

'宣告
<GuidAttribute("a2f71dcd-984c-4fed-8395-1ca5588190d6")> _
Public Interface ContentControlContentUpdatingEventArgs
[GuidAttribute("a2f71dcd-984c-4fed-8395-1ca5588190d6")]
public interface ContentControlContentUpdatingEventArgs

ContentControlContentUpdatingEventArgs 型別會公開下列成員。

屬性

  名稱 說明
公用屬性 Content 從已繫結至控制項的自訂 XML 組件,取得或設定寫入內容控制項的文字。

回頁首

範例

下列程式碼範例會示範 ContentUpdatingStoreUpdating 事件的事件處理常式。 這個範例假設文件中包含名為 plainTextContentControl1 且繫結至自訂 XML 組件中之項目的 PlainTextContentControl。 如需示範如何將內容控制項繫結至自訂 XML 組件中項目的程式碼範例,請參閱逐步解說:將內容控制項繫結至自訂 XML 組件

若要使用這段程式碼,請將它貼到專案的 ThisDocument 類別中。 若為 C#,您還必須將事件處理常式附加至 plainTextContentControl1 的 ContentUpdatingStoreUpdating 事件。

這是示範文件層級自訂的範例。

Private Sub plainTextContentControl1_StoreUpdating(ByVal sender As Object, _
    ByVal e As Microsoft.Office.Tools.Word.ContentControlStoreUpdatingEventArgs) _
    Handles PlainTextContentControl1.StoreUpdating

    MessageBox.Show("The control was changed to the following value: " & vbCrLf & _
        e.Content & vbCrLf & "This value is about to be written to the node that is bound to this control.")
End Sub

Private Sub plainTextContentControl1_ContentUpdating(ByVal sender As Object, _
    ByVal e As Microsoft.Office.Tools.Word.ContentControlContentUpdatingEventArgs) _
    Handles PlainTextContentControl1.ContentUpdating

    MessageBox.Show("The node that is bound to this control was changed to the following value: " & vbCrLf & _
        e.Content & vbCrLf & "This value is about to be written to this control.")
End Sub
void plainTextContentControl1_StoreUpdating(object sender, 
    Microsoft.Office.Tools.Word.ContentControlStoreUpdatingEventArgs e)
{
    MessageBox.Show("The control was changed to the following value: \n\n" +
        e.Content + "\n\nThis value is about to be written to the node that is bound to this control.");
}

void plainTextContentControl1_ContentUpdating(object sender, 
    Microsoft.Office.Tools.Word.ContentControlContentUpdatingEventArgs e)
{
    MessageBox.Show("The node that is bound to this control was changed to the following value: \n\n" +
        e.Content + "\n\nThis value is about to be written to this control.");
}

請參閱

參考

Microsoft.Office.Tools.Word 命名空間

其他資源

內容控制項

自訂 XML 組件概觀

逐步解說:將內容控制項繫結至自訂 XML 組件