Export (0) Print
Expand All

ContentControlBase.ContentUpdating Event

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Occurs just before Microsoft Office Word updates the text in the content control, if the content control is bound to a custom XML part.

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word (in Microsoft.Office.Tools.Word.dll)

event ContentControlContentUpdatingEventHandler ContentUpdating

You can bind content controls to an element in a piece of XML (also named custom XML part) that is embedded in the document. For more information, see Content Controls and Custom XML Parts Overview.

The ContentUpdating event is raised only if the data in a custom XML part is modified when the document is open. This event is not raised when the document is opened and the data in a custom XML part was modified when the document was closed.

The following code example demonstrates event handlers for the ContentUpdating and StoreUpdating events. This example assumes that the document contains a PlainTextContentControl named plainTextContentControl1 that is bound to an element in a custom XML part. For a code example that demonstrates how to bind a content control to an element in a custom XML part, see Walkthrough: Binding Content Controls to Custom XML Parts.

To use this code, paste it into the ThisDocument class in your project. For C#, you must also attach the event handlers to the ContentUpdating and StoreUpdating events of plainTextContentControl1.

This example is for a document-level customization.

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

Show:
© 2014 Microsoft