ContentControlBase.StoreUpdating 事件

只在 Microsoft Office Word 更新已繫結至內容控制項之自訂 XML 組件中的資料之前發生 (也就是,在內容控制項中的文字變更之後)。

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

語法

'宣告
Event StoreUpdating As ContentControlStoreUpdatingEventHandler
event ContentControlStoreUpdatingEventHandler StoreUpdating

備註

您可以將內容控制項繫結至內嵌於文件中之 XML 片段中的項目 (又稱為「自訂 XML 組件」)。 如需詳細資訊,請參閱 內容控制項自訂 XML 組件概觀

當內容控制項中的文字變更,而內容控制項已繫結至自訂 XML 組件中的項目時,會引發 StoreUpdating 事件。

如需處理事件的詳細資訊,請參閱使用事件

範例

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

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

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.");
}

.NET Framework 安全性

請參閱

參考

ContentControlBase 介面

Microsoft.Office.Tools.Word 命名空間

其他資源

內容控制項

自訂 XML 組件概觀

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